p.132 of Agile Web book has these two lines…
but it seems that they cause an error when “rake db:migrate”
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)”
gives:
(i tried a different table called “foo”)
C:\rails\depot>rake db:migrate
(in C:/rails/depot)
– execute(“alter table foos add constraint fk_foo_products \n
foreign key (
product_id) references products(id)”)
rake aborted!
Mysql::Error: Table ‘depot_development.foos’ doesn’t exist: alter table
foos add
constraint fk_foo_products
foreign key (product_id) references products(id)
(See full trace by running task with --trace)