On Jul 20, 2:23 pm, DBC User
<dbcu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi All,
>
> I am trying add a foreign key using db:migrate and getting error. I
> didn''t any documentation on the syntax, if some one has a link,
please
> send it to me if not, please have a look at the following and tell me
> what am I doing wrong?
>
> class name < ActiveRecord:Migration
> def self.up
> create_table :master ...
> end
>
> add_index :fav, ["lid"], :name => "fk_lid"
>
> create_table:child ....
> end
>
> add_constraint "fk_lid" foreign_key ( "lid" )
references :child
> ("id")
> end
>
> def self.down
> drop_table :child
> drop_table :master
> end
> end
Here is the link that had a good example
http://www.robbyonrails.com/articles/2005/11/11/rails-migrations-and-postgresql-constraints
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---