On Nov 5, 9:39 am, Phillip Koebbe <[EMAIL PROTECTED]>
wrote:
> The syntax that I use for PostgreSQL is this:
>
> def foreign_key(foreign_table, foreign_column, primary_table,
> primary_column = :id)
> execute "
> alter table #{foreign_table.to_s}
> add constraint fk_#{foreign_table.to_s}_#{foreign_column.to_s}
> foreign key (#{foreign_column.to_s}) references
> #{primary_table.to_s} (#{primary_column.to_s})
> "
> end
>
> def delete_foreign_key(foreign_table, foreign_column)
> execute "alter table #{foreign_table.to_s} drop constraint
> fk_#{foreign_table.to_s}_#{foreign_column.to_s}"
> end
>
> Put those methods in a file that gets loaded and use them like
>
> foreign_key :orders, :customer_id, :customers
>
> and
>
> delete_foreign_key :orders, :customer_id
I'm not sure, but I think there's something missing: the class name.
Or isn't that necessary here? If yes, can we put a name to it or what
kind of class is it?
It's a shame my ver. doesn't have the initializer thing. I'll try that
right now.
Greetings!
The Neurochild
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---