Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rdoc

active_record_foreign_keys

Foreign keys support for ActiveRecord.

THE PROJECT IS DEPRECATED. Please, use github.com/lomba/schema_plus

Install

Rails::Initializer.run do |config|
  ...
  config.gem "active_record_foreign_keys", :source => "http://gemcutter.org"
  ...
end

$ rake gems:install

Usage

def self.up
  # create reference table
  create_table :users do |t|
  end

  # create referencing table
  create_table :a_examples do |t|
    t.references :user, :foreign_key => true
  end

  # or
  create_table :b_examples do |t|
    t.references :user, :foreign_key => { :on_update => :cascade, :on_delete => :restrict }
  end

  # or
  create_table :c_examples do |t|
  end

  add_foreign_key :c_examples, :user_id, :users, :id, :on_update => :no_action, :on_delete => :set_null

  # or change existing table
  change_table :d_examples do |t|
    t.references :user, :foreign_key => true
  end
end

def self.down
  # remove constraint
  remove_foreign_key :examples, :user_id, :users, :id
end

Copyright © 2009 Anton Ageev. See LICENSE for details.

About

Foreign keys support for ActiveRecord

Resources

License

Languages

You can’t perform that action at this time.