# Foreign Keys and Testing

**URL:** <https://www.ruby-forum.com/t/foreign-keys-and-testing/113203>\
**Category:** Rails\
**Created:** [August 28, 2007, 6:48pm UTC](https://www.ruby-forum.com/t/foreign-keys-and-testing/113203 "2007-08-28T18:48:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Kroman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Alex\_Kroman](https://www.ruby-forum.com/u/Alex_Kroman)\
**Post date:** [August 28, 2007, 6:48pm UTC](https://www.ruby-forum.com/t/foreign-keys-and-testing/113203/1 "2007-08-28T18:48:55Z")

</div>

I recently started an application that is using foreign key  
constraints in the database. How do I get these constraints to be  
placed in the test database to ensure that my tests are running on the  
same schema that my application is?

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![Alex\_Kroman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Alex\_Kroman](https://www.ruby-forum.com/u/Alex_Kroman)\
**Post date:** [August 28, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/foreign-keys-and-testing/113203/2 "2007-08-28T20:57:59Z")

</div>

Alex Kroman wrote:

> I recently started an application that is using foreign key  
> constraints in the database. How do I get these constraints to be  
> placed in the test database to ensure that my tests are running on the  
> same schema that my application is?

The foreign\_key\_migrations plugin [1] will make this happen for you, if  
you create foreign keys using migrations like that plugin prescribes.

[1] [http://www.redhillonrails.org/](http://www.redhillonrails.org/)

–  
Roderick van Domburg

> **[De domeinnaam Nedforce.nl is te koop.](http://www.nedforce.nl)**
>
> Deze mooie domeinnaam kan al over een paar minuten van jou zijn. Betalen gaat eenvoudig en vertrouwd via iDEAL. Direct na de betaling ontvang je de verhuiscode per e-mail en kun je aan de slag.
