AR Add Constraint plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install svn://rubyforge.org//var/svn/araddconstraint/trunk
Create an FK to support a default rails has_many / belongs_to
create_table :posts do |t| t.column :title, :string t.column :body, :text end create_table :comments do |t| t.column :contents, :text t.column :post_id, :integer end add_foreign_key :comments, :posts
(creates an FK constraint called fk_comments_posts from comments.post_id to posts.id)
Custom source column
create_table :posts do |t| t.column :title, :string t.column :body, :text end create_table :comments do |t| t.column :contents, :text t.column :my_parent_post_id, :integer end add_foreign_key :comments, :posts, :source_column => :my_parent_post_id
(creates an FK constraint called fk_comments_posts from comments.my_parent_post_id to posts.id)
Custom key name
create_table :programmers do |t| t.column :name, :string end create_table :pairs do |t| t.column :first_id, :integer t.column :second_id, :integer end add_foreign_key :pairs, :programmers, :source_column => :first_id, :name => :fk_first_programmer add_foreign_key :pairs, :programmers, :source_column => :second_id, :name => :fk_second_programmer
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, 9 months ago

