Let’s say I did the
C:\rails\depot> ruby script/generate model line_item
and then forgot to modify the
007_create_line_items.rb
to add the table fields, but have done the
C:\rails\depot> rake db:migrate
so in this case, how can i undo them and restart?
I tried
C:\rails\depot> rake db:migrate VERSION=6
to remove the table, and then
C:\rails\depot> ruby script/destroy model line_item
and then start from the very beginning… generate the model, edit the
007_create_line_items.rb, and rake db:migrate…
but rake will report the table line_items doesn’t exist:
C:\rails\depot>rake db:migrate
(in C:/rails/depot)
– execute(“alter table line_items add constraint fk_line_item_products
\n f
oreign key (product_id) references products(id)”)
rake aborted!
Mysql::Error: Table ‘depot_development.line_items’ doesn’t exist: alter
table li
ne_items add constraint fk_line_item_products
foreign key (product_id) references products(id)
(See full trace by running task with --trace)
So how can it be done? How can the migration create the table once
again?