Sha256: 332e97487aa4df56a82a7e3a43e491cc4ed761acde65b041134e4cbd152c0cfa
Contents?: true
Size: 1.94 KB
Versions: 80
Compression:
Stored size: 1.94 KB
Contents
= Foreign Key Migrations Foreign Key Migrations is a plugin that automatically generates foreign-key constraints when creating tables. It uses SQL-92 syntax and as such should be compatible with most databases that support foreign-key constraints. In the simplest case, the plugin assumes that if you have a column named +customer_id+ that you want a foreign-key constraint generated that references the +id+ column in the +customers+ table: create_table :orders do |t| t.column :customer_id, :integer, :null => false ... end If you have multiple columns referencing a table or for whatever reason, your column name isn't the same as the referenced table name, you can use the <code>:references</code> option: create_table :orders do |t| t.column :ordered_by_id, :integer, :null => false, :references => :customers ... end If you have a column with a name ending in +_id+ for which you do not wish a foreign-key to be generated, you can use <code>:references => nil</code>: create_table :orders do |t| t.column :external_id, :integer, :null => false, :references => nil ... end You also have the option of specifying what to do on delete/update using <code>:on_delete</code>/<code>:on_update</code>, respectively to one of: <code>:cascade</code>; <code>:restrict</code>; and <code>:set_null</code>: create_table :orders do |t| t.column :customer_id, :integer, :on_delete => :set_null, :on_update => :cascade ... end The plugin fully supports and understands the following active-record configuration properties: * <code>config.active_record.pluralize_table_names</code> * <code>config.active_record.table_name_prefix</code> * <code>config.active_record.table_name_suffix</code> === Dependencies * RedHill on Rails Core (redhillonrails_core). === See Also * Foreign Key Associations (foreign_key_associations). === License This plugin is copyright 2006 by RedHill Consulting, Pty. Ltd. and is released under the MIT license.
Version data entries
80 entries across 80 versions & 1 rubygems