P.132 of Agile Web book error?

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)

Summercool Summercool wrote:

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)”

i found the error… visually, the code looks like in between self.up
and down…
and then actually, the code is in the up definition… outside of up it
will give error.