Closed istr closed 9 years ago
Why do you think that CommonHelpers.module_names_in_path
needs to return modules names ordered alphabetically?
Because a migration may depend on a previous migration so it is vital to execute them in order. Example: current migration: migrations/20140622141203.lua migrations/20140625174238.lua creates a table: CREATE TABLE foo (id SERIAL, bar INTEGER); migrations/20140625185527.lua alters that table: ALTER TABLE foo ADD COLUMN op INTEGER;
Now you want to apply these two migrations on a host that has 20140622141203 as its last migration. If these are executed in arbitrary order, migration may fail. The same applies to rollbacks.
It could be sufficient to sort within Migrations.migration_modules only, but more often than not it is preferable to have deterministic rather than arbitrary behaviour, so I just put it into the helper function.
Note: you may pull https://github.com/ostinelli/gin/pull/9 as well, because it adresses the same problem and provides the option to run specific migrations.
Ok thank you. #9 does not pass tests. I've asked @leite to fix tests and I'll merge that one in.
You have 2 pull requests with the same issue, I've closed #11. I'm assuming we'll wait to see if @leite's one gets merged in depending on tests being fixed. Thank you.
Ok, closing in favour of pull request https://github.com/ostinelli/gin/pull/9 brought in by @leite.
I merged in current master branch into istr:sortmigrate because @leite did not follow up on his pull request. My version does the work and passes the busted test.
Thank you @istr will review soon.
Hello @istr, can you please fork out of current master and generate a single squashed commit with all your changes. Will apply when done.
As you can see some of this is already in master: f77b0ecf3eefafc90dd49256907a3a589b18a0ae
Thank you.
Ok, so hopefully I got it right with git this time... ;-) My "bread and butter" RCS is http://fossil-scm.org which is way easier to handle. See pull request from my branch "orderedmigration".