Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does new Rails db migration file start with datestamp instead of sequence number?

Whenever I use script/generate to generate a new scaffold for a change to my Rails database, the new migration file is prepended by a datestamp (e.g. 200903140912_create_users.rb) instead of a sequence number (e.g. 004_create_users.rb).

I then have to manually change the file name to fit in with the rest of the migration files.

Does anyone know how to fix this?

System: Mac OS X Leopard 10.5.6
Rails: v2.2.2
Ruby: v1.8.6

like image 396
user9945 Avatar asked Dec 03 '22 08:12

user9945


2 Answers

This was introduced in Rails 2.1. According to the migrations docs, you can revert it by setting config.active_record.timestamped_migrations to false in config/environment.rb.

like image 83
James Gregory Avatar answered Dec 04 '22 20:12

James Gregory


I'm not sure why they made the decision, but I can tell you how it's made my life easier. On a team it was common for two people to create migrations at roughly the same time. If the last production migration was 007 then both of the new ones would be 008. The second person to commit would have a headache on their hands trying to sort it out, and the timestamps make that conflict a lot less likely.

like image 42
jshen Avatar answered Dec 04 '22 22:12

jshen