This PR adds support for migration scripts with nobrainer, heavily inspired from the ActiveRecord Migration Script concept (meaning familiar to RoR people that we are).
Migration script is really helpful in the data migration concern. Fix wrongly created data, deleting old data and more, can be easily done with migration scripts.
It is especially true as I've implemented the Capistrano integration too, exactly as AR is doing.
I've added a very basic generator which generates a migration script file named the same way as AR does. The migration scripts are inheriting from the new NoBrainer::Migration class which holds the logic of running up then down if up failed.
Finally the new NoBrainer::Migrator class contains the heart of this PR and take care of:
creating a table to store the script versions (well its timestamp, like AR does) to run the script only once
run in a Benchmark.measure block the migration script and shows the execution time (I've stoled the announce method from ActiveRecord)
save or delete the script version
The migrator supports both migrating all non executed scripts, and rollbacking the last script only.
So it's a very minimal implementation with tests everywhere AFAIK.
I'm using this branch for a production project at work and it works pretty well. I really hope you'll accept it 🙏. I'm of course ready to fix all the things that would need it.
This PR adds support for migration scripts with nobrainer, heavily inspired from the ActiveRecord Migration Script concept (meaning familiar to RoR people that we are).
Migration script is really helpful in the data migration concern. Fix wrongly created data, deleting old data and more, can be easily done with migration scripts. It is especially true as I've implemented the Capistrano integration too, exactly as AR is doing.
I've added a very basic generator which generates a migration script file named the same way as AR does. The migration scripts are inheriting from the new
NoBrainer::Migration
class which holds the logic of runningup
thendown
ifup
failed.Finally the new
NoBrainer::Migrator
class contains the heart of this PR and take care of:Benchmark.measure
block the migration script and shows the execution time (I've stoled theannounce
method from ActiveRecord)The migrator supports both migrating all non executed scripts, and rollbacking the last script only.
So it's a very minimal implementation with tests everywhere AFAIK.
I'm using this branch for a production project at work and it works pretty well. I really hope you'll accept it 🙏. I'm of course ready to fix all the things that would need it.