# P.132 of Agile Web book error?

**URL:** <https://www.ruby-forum.com/t/p-132-of-agile-web-book-error/114604>\
**Category:** Rails\
**Created:** [September 17, 2007, 11:33am UTC](https://www.ruby-forum.com/t/p-132-of-agile-web-book-error/114604 "2007-09-17T11:33:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 17, 2007, 11:33am UTC](https://www.ruby-forum.com/t/p-132-of-agile-web-book-error/114604/1 "2007-09-17T11:33:22Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [September 17, 2007, 12:57pm UTC](https://www.ruby-forum.com/t/p-132-of-agile-web-book-error/114604/2 "2007-09-17T12:57:11Z")

</div>

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.
