# Db:schema:dump constraints query

**URL:** <https://www.ruby-forum.com/t/dbdump-constraints-query/87610>\
**Category:** Rails\
**Created:** [March 4, 2007, 1:08pm UTC](https://www.ruby-forum.com/t/dbdump-constraints-query/87610 "2007-03-04T13:08:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![akm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/57b2e6/32.png) [@akm](https://www.ruby-forum.com/u/akm)\
**Post date:** [March 4, 2007, 1:08pm UTC](https://www.ruby-forum.com/t/dbdump-constraints-query/87610/1 "2007-03-04T13:08:51Z")

</div>

‘Create a db/schema.rb file that can be portably used against any DB  
supported by AR’

This definition I understand fully, but is there a reason why key  
constraints are not carried across? For instance I have a primary key  
constraint on a table in my postgreSQL dB as such:

‘ALTER TABLE orderstbl  
ADD CONSTRAINT orderstbl\_pkey PRIMARY KEY(order\_id);’

but in my schema.rb file the table is simply presented as:

create\_table “orderstbl”, :id =\> false, :force =\> true do |t|  
t.column “order\_id”, :string, :null =\> false  
t.column “version”, :integer, :null =\> false  
t.column “price\_total”, :integer, :null =\> false  
t.column “order\_date”, :datetime, :null =\> false  
t.column “user\_id”, :integer, :null =\> false  
t.column “user\_ip”, :string  
t.column “downloaded”, :boolean, :null =\> false  
t.column “merchant\_id”, :integer, :null =\> false  
t.column “merchant\_transaction\_id”, :string, :null =\> false  
t.column “downloaded\_date”, :datetime  
end

How can I force the schema:dump to carry across at least the  
primary/foreign  
key constraints? The process manages to ‘add\_index’ but nothing else!!

–  
Regards

Andrew
