Rake db:migrate


#1

I created a model and specify the columns in the database table. But
when I use “rake db:migrate” to migrate the database table. It keeps
igoring the command. (but not Aborted) it just does not give any result,
and the table was not created in the database.

When I tried it in another project folder and did exactly the same
thing, it worked. It just does not work in that specific project.

Does anyone know what the problem is? Thanks for help.


#2

hao min wrote:

I created a model and specify the columns in the database table. But
when I use “rake db:migrate” to migrate the database table. It keeps
igoring the command. (but not Aborted) it just does not give any result,
and the table was not created in the database.

When I tried it in another project folder and did exactly the same
thing, it worked. It just does not work in that specific project.

Does anyone know what the problem is? Thanks for help.

I think you may be confused about migration. If you “specify the
columns in the database table” then you are not using migrations.

“rake db:migrate” makes sure your database is up to date by executing
the files in db/migrations/xxx_create_some_table.rb

  1. ruby script/generate model SomeModel
    or
    ruby script/generate migration AddFooToBars

  2. Edit the new file in db/migrations that was just created.

  3. Now run “rake db:migrate” The database changes you just defined
    should be applied to your database.


#3

I think you may be confused about migration. If you “specify the
columns in the database table” then you are not using migrations.

“rake db:migrate” makes sure your database is up to date by executing
the files in db/migrations/xxx_create_some_table.rb

  1. ruby script/generate model SomeModel
    or
    ruby script/generate migration AddFooToBars

  2. Edit the new file in db/migrations that was just created.

  3. Now run “rake db:migrate” The database changes you just defined
    should be applied to your database.

Hi, Alex That is what I have done for my “Order” model. After I
generate the model, I edited "create_orders"file in the migration folder
and then rake db:migrate
The result is like what I described above.