Simple migration problem

Hi:

I’m running RoR 1.1

I’m going through the Agile book Depot example and I want to generate my
next migration file so i’m typing

./script/generate migration depot

I was sort of expecting to get the file 002_depot.rb … instead i’m
being informed that there already exists a migration named depot…and no
new file is generated…

should I be using a new name? I tried that accidentally and got
002_help.rb

?

The agile book came out while migrations were a work in progress, so it
doesn’t really cover this.

If you look at the file you create you will notice that the migration
creates a class with a name the same as you gave in the migration:

class Products < ActiveRecord::Migration

end

this is without the 001_ or 002_, so you would have a clas name conflict
if you use the same name twice.

Here is a link to some docs:
http://api.rubyonrails.com/classes/ActiveRecord/Migration.html

-Sean

Andrew wrote:

Hi:

I’m running RoR 1.1

I’m going through the Agile book Depot example and I want to generate my
next migration file so i’m typing

./script/generate migration depot

I was sort of expecting to get the file 002_depot.rb … instead i’m
being informed that there already exists a migration named depot…and no
new file is generated…

should I be using a new name? I tried that accidentally and got
002_help.rb

?

Thank you Rob and Sean… the class name argument makes perfect sense.

cheers!

Different name definitely.

To get help, just leave out the final arg:
./script/generate migration

Did you know that if you generate model Foo that it will create the
migration for create_foos automatically?

-Rob

Rob B. http://agileconsultingllc.com
[email protected]
+1 513-295-4739