# Re: PostgreSQL 8.1, testing with constraints

**URL:** <https://www.ruby-forum.com/t/re-postgresql-8-1-testing-with-constraints/51241>\
**Category:** Rails\
**Created:** [November 30, 2005, 8:17pm UTC](https://www.ruby-forum.com/t/re-postgresql-8-1-testing-with-constraints/51241 "2005-11-30T20:17:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/858c86/32.png) [@drbrain](https://www.ruby-forum.com/u/drbrain)\
**Post date:** [November 30, 2005, 8:17pm UTC](https://www.ruby-forum.com/t/re-postgresql-8-1-testing-with-constraints/51241/1 "2005-11-30T20:17:26Z")

</div>

On Nov 30, 2005, at 10:40 AM, removed\_email\_address@domain.invalid wrote:

> without the foreign key constraints, they run fine, but blow up when I  
> active\_record/connection\_adapters/abstract\_adapter.rb:67:in  
> `log’: ERROR: relation “users” already exists  
> (ActiveRecord::StatementInvalid)
> 
> I assume that it’s not able to drop the users table because of a  
> foreign key constraint in the messages table. I’m not using the  
> messages fixture in these unit tests though, so it shouldn’t matter.
> 
> I want to use foreign key constraints in my database, but I also want  
> to be able to unit test my code. What am I missing here?

[http://dev.rubyonrails.org/ticket/2404](http://dev.rubyonrails.org/ticket/2404)

–  
Eric H. - removed\_email\_address@domain.invalid - [http://segment7.net](http://segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![drbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/858c86/32.png) [@drbrain](https://www.ruby-forum.com/u/drbrain)\
**Post date:** [November 30, 2005, 8:37pm UTC](https://www.ruby-forum.com/t/re-postgresql-8-1-testing-with-constraints/51241/2 "2005-11-30T20:37:46Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Nov 30, 2005, at 11:25 AM, Pat M. wrote:

> I only specify the  
> users and the tickets fixtures, but it complains that some record in  
> the messages table references a user record. There shouldn’t be any  
> messages records though, so I’m just confused.

This is the same issue covered in ticket #2404 which Eric linked to.

jeremy  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDjf7pAQHALep9HFYRAsvAAJ9x098LIJXK4B5JCl4NmbzMMSuKYACeKISW  
VVXLCWDuMdeqBeF+9jrrKws=  
=k5CY  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![drbrain](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/858c86/32.png) [@drbrain](https://www.ruby-forum.com/u/drbrain)\
**Post date:** [November 30, 2005, 8:29pm UTC](https://www.ruby-forum.com/t/re-postgresql-8-1-testing-with-constraints/51241/3 "2005-11-30T20:29:39Z")

</div>

I actually figured out the answer to this problem, it was because of a  
custom test\_helper.rb file in the LoginEngine. However as I mentioned  
in a reply, one of my unit tests is complaining about a fixture that  
shouldn’t even be loaded in that particular file. I only specify the  
users and the tickets fixtures, but it complains that some record in  
the messages table references a user record. There shouldn’t be any  
messages records though, so I’m just confused.
