views:

26

answers:

2

I'm using NetBeans + Rails 2.3.8.

I notice that whenever I generate a model, the migration filename for it includes the date and time:

  • Model Name: User
  • Migration File Name : 20100916172053_create_users.rb

But when I see books (like Agile Web Development with Rails), the (rake-generated examples int it) all show simple numbers like 001_create_users, 002_create_sessions etc.

How do I get that simple numbering scheme (it looks neater, easier on the eyes when searching for a model)?

Or is it better to just go with the flow and not bother about what kind of versioning number is used?

+5  A: 

You can add this to config/environment.rb

config.active_record.timestamped_migrations = false

Note that the default was changed to timestamps because it (the numbering version) causes problems in multi-developer environments. When two developers both create a migration between source control updates, the migrations will have the same numbers. If you are working alone that would not be a problem.

Also, I'm not sure how it will work if you already have existing migrations, so be careful if that is the case.

ngoozeff
Thanks for the info. I tried the option with existing timestamped migrations, and the config option did not work. Doing it in a fresh app worked just fine.
Zabba
+1  A: 

The migrations wth the timestamp are the newer form as that allows more than one person at a time to add a migration to the project. This is particularily useful in projects with more than one developer as with the old numbered approach you would need to add the migrations in lock step or renumber them.

So I would recommend that you stick with the timestamp form.

However if you still want to use the older numbered forms you can do as @ngoozeff suggested and add:

config.active_record.timestamped_migrations = false

to either your environment.rb or an initializer.

Daemin