Migrations problem with Agile Rails book

I am following the instructions on Agile Web D. with Rails book
“Iteratio E1: Capturing
an Order” section. When I run the migrations I get the following error.

rake db:migrate
(in /Users/balaparanj/work/depot)
– execute("alter table line_items \n

add constraint fk_line_item_products \n
foreign key (product_id) references products(id)")
rake aborted!
Mysql::Error: Table ‘depot_development.line_items’ doesn’t exist: alter
table line_items
add constraint fk_line_item_products
foreign key (product_id) references products(id)

(See full trace by running task with --trace)

Could some one please tell me how to fix this problem? TIA.

http://www.ProblemSolvingSkill.net
Hone your problem-solving skills

First question has to be did you check that the table line_items has
been created in the depot_development database? Should have done a
create table in a previous migration or used the mysql command line to
add the table previous to running this migration.

Bala P. wrote:

I am following the instructions on Agile Web D. with Rails book
“Iteratio E1: Capturing
an Order” section. When I run the migrations I get the following error.

rake db:migrate
(in /Users/balaparanj/work/depot)
– execute("alter table line_items \n

add constraint fk_line_item_products \n
foreign key (product_id) references products(id)")
rake aborted!
Mysql::Error: Table ‘depot_development.line_items’ doesn’t exist: alter
table line_items
add constraint fk_line_item_products
foreign key (product_id) references products(id)

(See full trace by running task with --trace)

Could some one please tell me how to fix this problem? TIA.

http://www.ProblemSolvingSkill.net
Hone your problem-solving skills

Thank you. I resolved the problem. I commented out the following two
lines in
006_create_line_items.rb.

execute “alter table line_items
add constraint fk_line_item_products
foreign key (product_id) references products(id)”

execute “alter table line_items
add constraint fk_line_item_orders
foreign key (order_id) references orders(id)”

Ran the migrations and then uncommented them and again ran the
migrations. First time it created
the tables, second time it added the constraints. Hope this helps other
readers.

— Paul C. [email protected] wrote:

rake db:migrate


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

http://www.ProblemSolvingSkill.net
Hone your problem-solving skills

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs