This project is archived and is in readonly mode.
Migration timestamp clash problems with generators
-
Ben Scofield
Here's a patch for the issue; it appends the microsecond time to the timestamp. Unfortunately, however, it appears that this area of railties is entirely untested, and I was sure that it would be wise to launch into a whole new suite of unit tests (though I can add those if it would help)
-
Ben Scofield
OK, ignore the previous patch :)
After consulting with bitsweat, I've expanded the patch for the issue by adding a new test file (rails_migration_generator_test.rb) that shows the problem.
-
Brian Landau
+1 This is a common issue for anyone developing new plugins/gems that use generators, or when creating personal generators.
-
Russell Quinn
+1 Good work! It certainly seems bad that migrations are now bound to a "rate" of one per second. If the whole purpose of 2.0 migrations were to ensure uniqueness then it seems to fail usage tests.
-
Ben Scofield
OK, after chatting with DHH and bitsweat, it appears that the appropriate action is to consolidate migrations in generators instead of trying to make the timestamps more granular. (There's also a concern that microseconds may lengthen the timestamp so that it overflows some database column constraints.)
This can be closed.
-
Mark Bates
I am now just running into this problem with a gem of mine, and I can't disagree more that just 'consolidating' migrations is a good idea.
Here's an example:
v1 of the gem has a migration.
v2 of the gem has a migration that updates the tables from the first migration.If you consolidate them into one, then the people who are upgrading from v1 - v2 will have a second migration that will raise errors on them because the tables already exist from the first migration. You can just comment it out, either because you might be adding new columns to the existing tables.
Of course you could right insane amounts of checks in your migrations that check to see what version you are on and hopefully run the correct schema changes, but isn't that why we have migrations?
I implore you to re-open this ticket. It's just not a good solution.
-
Kevin Elliott
I strongly agree with Mark Bates that this ticket should be re-opened and evaluated. His example is a good case for why a compressed migration will not work.
Expecting to follow the ticket's current solution would be similar to forcing all rails apps to abandon migrations and only use a schema file.
I, too, am requesting that this be looked at for an alternative solution.
-
Basel Farah
I have had the same problem trying to copy migrations with a generator, the only way I could do it is to add some delay between the creation of migrations, smply by adding:
m.migration_template "db/migrate/add_session_table.rb", "db/migrate", :migration_file_name => 'add_session_table'
m.sleep 1 #adds a delay of 1 second between creating these 2 migrations
m.migration_template "db/migrate/create_casein_users.rb", "db/migrate", :migration_file_name => 'create_casein_users'result:
.rb.rb
this solved my problem for the moment, hope this helps.
-
adlongwell
I was about to agree with Mark Bates on this ticket, but I think Basel's solution (m.sleep 1) is an excellent alternative. It works well for my purposes.
-
Russell Quinn
m.sleep 1 might work, but it feels dark.
-
kevinwu007
I love 1 saints super bowl jersey!Below 2 the authentic nfl jerseys trees, I saw 3 some [link=http://www.pickson.com/indianapolis-colts-jerseys-c-40.html]peyton manning jersey[/link] balloons and butterflies in the sky. we went 4 to [url=http://www.pickson.com/indianapolis-colts-jerseys-c-40.html]colts nfl jerseys[/url] the zoo. In the afternoon, we went 5 to [colts nfl jerseys->http://www.pickson.com/indianapolis-colts-jerseys-c-40.html] the zoo. I visited the birds, mice, cats, dogs, budgies, hamsters, rabbits and so on.
