Links
MySQL Foreign keys
Categories
MySQL Foreign keys
Provides add_foreign_key and remove_foreign_key to migrations:
class CreatePeople < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.string :name, :null => false
t.references :address
end
add_foreign_key :people, :addresses
end
def self.down
drop_table :people
end
end
If your foreign key isn’t named like <table_name>_id you can do:
add_foreign_key :people, :addresses, :location_id
Vitals
| Home | http://www.cjohansen.no/projects/mysql_foreign_keys |
|---|---|
| Repository | https://svn.cjohansen.no/rails/plugins/mysql_foreign_keys/trunk/ |
| License | Rails' (MIT) |
| Rating | (1 vote) |
| Owner | Christian Johansen |
| Created | 26 October 2008 |
Comments
-
I'm afraid that this is being a duplicit plugin. Check out foreign key migrations plugin - http://www.redhillonrails.org/ (it adds foreign keys automatically or you can set manually and it works with any database supporting foreign keys)
