Plugins - Foreign Key Schema Dumper

StarAdd to favorites

This plugin adds support for Foreign Key Constraints in schema dumper. After adding this plugin, do a rake dbschemadump and you'll see statements for adding constraints in your schema.rb. (Works with MySQL, and PostgreSQL)

You can use this plugin for your migrations as well. The syntax for adding FK constraints is:

add_foreign_key_constraint table, foreign_key, reference_table, reference_column, 
:name => optional_constraint_name, 
:on_update => optional_on_update_action, 
:on_delete => optional_on_delete_action

The actions are symbols. One of: :cascade, :set_null, or :restrict If you don't want any action, "no action", then just omit these optional parameters.

For removing:

You have two options:

  1. :name => the name of the foreign key constraint
  2. :foreignkey => the name of the column for which the foreign key was created (only if the default constraintname was used)

*Note*: This is for inside ActiveRecord::Schema not inside migrations. You can use removeforeignkey_constraint but it takes just the table name and constraint name

http://wiki.rubyonrails.org/rails/pages/Foreign+Key+Schema+Dumper+Plugin

  • Currently 4.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Misc. Enhancements

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?