# Fixtures, Postgres & Constraints

**URL:** <https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081>\
**Category:** Rails\
**Created:** [March 28, 2006, 1:28am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081 "2006-03-28T01:28:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [March 28, 2006, 1:28am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081/1 "2006-03-28T01:28:54Z")

</div>

Anyone have any tips for handling postgres constraints when using  
fixtures to load the database, other than to sort out the proper  
insertion orders or leaving the constraints out? I’d prefer not to do  
the former since I’d rather use my app to generate my fixture data  
(using a dump\_fixtures task) and I’d prefer not to do the latter  
because leaving out constraints till the end makes it easy (for me) to  
forget one or two. The use case here is that I’m trying to synch my  
entire app (including database schema and data) between two of my  
development machines (laptop and desktop) using only subversion and  
rake. Migrations aren’t really the answer because this isn’t about  
promotion, just rapid synching from a single script I can run on  
either machine.

–  
Jeremy H.

> **[Jeremy Huffman, the Website - jeremyhuffman.com](https://jeremyhuffman.com/)**
>
> Jeremy Huffman, the Website
>         
>       
>     
>     
> Getting in Touch
> 
> You can email me if you can guess the addres...

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [March 28, 2006, 1:38am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081/2 "2006-03-28T01:38:13Z")

</div>

On Mon, 2006-03-27 at 18:27 -0500, Jeremy H. wrote:

> promotion, just rapid synching from a single script I can run on  
> either machine.

* * *

true but working through the migrations got me to figure out the  
drop/add order and to use raw sql code to add to add the foreign key  
constraints back in so I am expecting that will give me a leg up on  
setting up testing (I’m hoping it will). Evidently migrations handles  
creating all of the primary key constraints for me so I stopped trying  
to do that myself.

Craig

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [March 28, 2006, 1:39am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081/3 "2006-03-28T01:39:55Z")

</div>

On Mon, 2006-03-27 at 18:27 -0500, Jeremy H. wrote:

> promotion, just rapid synching from a single script I can run on  
> either machine.

* * *

by the way, I don’t see a ‘dump fixtures’ option in ‘rake --tasks’ - is  
that a gem or a plugin?

Craig

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [March 28, 2006, 2:25am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081/4 "2006-03-28T02:25:43Z")

</div>

On Mon, 2006-03-27 at 18:58 -0500, Jeremy H. wrote:

> I’m writing migrations for promotion to stage and production but I  
> really this to be dead simple and I don’t want to mess with migrations  
> for every interim change; I’d rather get my app how I want it and  
> write migrations to handle the diffs.
> 
> The dump fixtures is just some simple code I found, but pretty useful.
> 
> [http://comments.gmane.org/gmane.comp.lang.ruby.rails/28315](http://comments.gmane.org/gmane.comp.lang.ruby.rails/28315)

* * *

any clue on where the table\_names definition would logically go since  
that is erb and it doesn’t seem logical to go into dump\_fixtures.rake

Craig

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [March 28, 2006, 4:56am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081/5 "2006-03-28T04:56:44Z")

</div>

Yes I had the same question - it does go in the dump\_fixtures.rake, I  
put it near the top with the other assignments.

On 3/27/06, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> > > > insertion orders or leaving the constraints out? I’d prefer not to do  
> > > > by the way, I don’t see a ‘dump fixtures’ option in ‘rake --tasks’ - is
> 
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Jeremy H.

> **[Jeremy Huffman, the Website - jeremyhuffman.com](https://jeremyhuffman.com/)**
>
> Jeremy Huffman, the Website
>         
>       
>     
>     
> Getting in Touch
> 
> You can email me if you can guess the addres...

---

<div class="post-metadata">

**Author:** ![jeremyheiler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jeremyheiler](https://www.ruby-forum.com/u/jeremyheiler)\
**Post date:** [March 28, 2006, 1:59am UTC](https://www.ruby-forum.com/t/fixtures-postgres-constraints/56081/6 "2006-03-28T01:59:26Z")

</div>

I’m writing migrations for promotion to stage and production but I  
really this to be dead simple and I don’t want to mess with migrations  
for every interim change; I’d rather get my app how I want it and  
write migrations to handle the diffs.

The dump fixtures is just some simple code I found, but pretty useful.

[http://comments.gmane.org/gmane.comp.lang.ruby.rails/28315](http://comments.gmane.org/gmane.comp.lang.ruby.rails/28315)

On 3/27/06, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > rake. Migrations aren’t really the answer because this isn’t about  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Jeremy H.

> **[Jeremy Huffman, the Website - jeremyhuffman.com](https://jeremyhuffman.com/)**
>
> Jeremy Huffman, the Website
>         
>       
>     
>     
> Getting in Touch
> 
> You can email me if you can guess the addres...
