Foreign Keys in Migrations


#1

Is there a way to create the db schema completely through the ruby
syntax in a migration?
If i want a relation between table there doesnt seem a way to create
it when having the environment table set to :ruby instead of :sql and
using migrations.

Thanks.


#2

On Thu, 5 Jul 2007, Ron wrote:

Is there a way to create the db schema completely through the ruby
syntax in a migration?
If i want a relation between table there doesnt seem a way to create
it when having the environment table set to :ruby instead of :sql and
using migrations.

I asked this one recently, so I can answer this:

You need the plugin called fixture_references. There’s not a whole lot
of documentation for it yet, so I quote the patch I sent them for an
INSTALL file:

Index: INSTALL

— INSTALL (revision 0)
+++ INSTALL (revision 0)
@@ -0,0 +1,5 @@
+# Change directory to the RAILS_ROOT for your project.
+# Then do:
+./script/plugin install http://svn.pluginaweek.org/trunk/plug
ins/active_record/migrations/fixture_references
+
+

More docs, well, discussion about how to use it at:
http://www.pluginaweek.org/2007/04/07/14-fix-your-fixtures-with-fewer-foreign-key-ids/

    HTH
    Hugh