Hi all, In the AWDR author use the execute method to declare foreign keys: execute "alter table.... add constraint.... foreign key...." Is there a ruby sintax to declare a foreign key in a migration class? -- Posted via http://www.ruby-forum.com/.
On 7/13/06, Eduardo Y??ez Parareda <eduardo.yanez@gmail.com> wrote:> Hi all, > > In the AWDR author use the execute method to declare foreign keys: > > execute "alter table.... add constraint.... foreign key...." > > Is there a ruby sintax to declare a foreign key in a migration class?I''ve not used it, but there is a foreign key migrations plugin. http://www.redhillconsulting.com.au/rails_plugins.html#foreign_key_migrations
> http://www.redhillconsulting.com.au/rails_plugins.html#foreign_key_migrationsThanks, I''m going to have a quick look at this -- Posted via http://www.ruby-forum.com/.
I didn''t realize the solution proposed in the book. Create a new module with a foreign_key method which invokes execute alter table, and include that module in the migration''s classes that need it. -- Posted via http://www.ruby-forum.com/.
Which book? On 7/14/06, Eduardo Y??ez Parareda <eduardo.yanez@gmail.com> wrote:> I didn''t realize the solution proposed in the book. Create a new module > with > a foreign_key method which invokes execute alter table, and include that > module > in the migration''s classes that need it. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 7/14/06, Pat Maddox <pergesu@gmail.com> wrote:> Which book?2nd edition of Agile Web Development With Rails. Page 268. -- James
I had problems with the foreign_key_migrations plugin. Is was possible to generate a contraint that was not removable via MySQL ddl. Only solution was to drop and re-create the database. Happened twice. ( In all fairness, I haven''t researched the problem, and haven''t contacted the autors about it). I am using the foreign_key_schema_dumper plugin in my current project. It provides to migration methods for managing foreign keys in migrations. add_foreign_key_constraint and remove_foreign_key_constraint You might want to look to see how they are implements, or just use them if they do what you want. my 2 cents -Larry On 7/14/06, James Ludlow <jamesludlow@gmail.com> wrote:> > On 7/14/06, Pat Maddox <pergesu@gmail.com> wrote: > > Which book? > > 2nd edition of Agile Web Development With Rails. Page 268. > > -- James > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Best Regards, -Larry "Work, work, work...there is no satisfactory alternative." --- E.Taft Benson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060714/618b410f/attachment.html