No commit activity in last 3 years
No release in over 3 years
Adds a add_foreign_key_constraint schema method, and extends the schema dump code to output these foreign key constraints. Only MySQL and PostgreSQL are currently supported. Examples ======== # adds a constraint on projects.customer_id with parent customers.id add_foreign_key :projects, :customer_id, :customers, :id # adds a constraint on projects(a, b) with parent(a, b) with the default RESTRICT update/delete actions add_foreign_key "child", ["a", "b"], "parent", ["a", "b"] # adds a constraint with the ON UPDATE action set to CASCADE and the ON DELETE action set to SET NULL add_foreign_key 'projects', 'customer_id', 'customers', 'id', :on_update => :cascade, :on_delete => :set_null The following actions are defined: :restrict :no_action :cascade :set_null (aka :nullify) :set_default Note that MySQL does not support :set_default, and also treats :no_action as :restrict. Compatibility ============= Supports mysql, mysql2, postgresql. Currently tested against Rails 3.2.13 on 2.0.0p0 and Rails 3.2.13, 3.1.8, 3.0.17, and 2.3.14 on Ruby 1.8.7.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0
>= 0

Runtime

 Project Readme
ForeignKeySaver
===============

This plugin adds an add_foreign_key_constraint schema method, and extends the
schema dump code to output these foreign key constraints.

Only MySQL and PostgreSQL are currently supported.


Examples
========

# adds a constraint on projects.customer_id with parent customers.id
add_foreign_key_constraint :projects, :customer_id, :customers, :id

# adds a constraint on projects(a, b) with parent(a, b) with the default RESTRICT update/delete actions
add_foreign_key_constraint "child", ["a", "b"], "parent", ["a", "b"]

# adds a constraint with the ON UPDATE action set to CASCADE and the ON DELETE action set to SET NULL
add_foreign_key_constraint 'projects', 'customer_id', 'customers', 'id', :on_update => :cascade, :on_delete => :set_null

The following actions are defined:
  :restrict
  :no_action
  :cascade
  :set_null (aka :nullify)
  :set_default
Note that MySQL does not support :set_default, and also treats :no_action as :restrict.


Compatibility
=============

Supports mysql, mysql2, postgresql.

Supported Rails 4.1, 4.0, 3.2.13, 3.1.8, 3.0.17, and 2.3.14.