#487 √ wontfix
Russell Quinn

Migration timestamp clash problems with generators

Reported by Russell Quinn | June 25th, 2008 @ 06:26 PM

Hello,

Creating multiple migrations automatically from a generate script causes problems with the new timestamp based migration filenames as they occur at the same second.

e.g.

m.migration_template "db/migrate/add_session_table.rb", "db/migrate", :migration_file_name => 'add_session_table'

m.migration_template "db/migrate/create_casein_users.rb", "db/migrate", :migration_file_name => 'create_casein_users'

creates:

20080625170543_add_session_table.rb

20080625170543_create_casein_users.rb

Obviously there's problems with autodetecting this and just incrementing the last digit, but maybe it's worth suffixing these clashes with a further qualifying digit? i.e. There's another level of granularity to mark up to 10 migrations created in the same second.

Russell.

Comments and changes to this ticket

  • Ben Scofield

    Ben Scofield September 2nd, 2008 @ 10:35 PM

    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

    Ben Scofield September 3rd, 2008 @ 06:53 PM

    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

    Brian Landau September 3rd, 2008 @ 07:07 PM

    +1 This is a common issue for anyone developing new plugins/gems that use generators, or when creating personal generators.

  • Russell Quinn

    Russell Quinn September 4th, 2008 @ 08:31 AM

    +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

    Ben Scofield September 4th, 2008 @ 01:48 PM

    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.

  • Jeremy Kemper

    Jeremy Kemper September 6th, 2008 @ 03:49 AM

    • → State changed from “new” to “wontfix”

    Cheers :) Thanks Ben.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

The Git repository resides at http://github.com/rails

Check out the current development trunk (Edge Rails) with:

git clone git://github.com/rails/rails.git

Creating or reviewing a patch

See the contributor guide.

Creating a feature request

Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.

Creating a bug report

When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.

Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.

Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".

Shared Ticket Bins