How to UNDO ruby script/generate model table and migration

Let’s say I did the

C:\rails\depot> ruby script/generate model line_item
and then forgot to modify the


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

Looks like the table did not get dropped. Either the down action in the
Migration did not include the drop command or the command rake
VERSION=6 did not succeed. To resolve the issue you need to take one of
following steps:

rake db:reset #Only works in Edge or w/ Sake
drop your database, recreate it and remigrate
drop the specific table that was causing the problem either from the
line or from a gui client.
add :force => true to your migrations table create line (think carefully
before doing this one)

Good Luck,
Rob K.