# artemk-migration_fu **Repository Path**: rubygems/artemk-migration_fu ## Basic Information - **Project Name**: artemk-migration_fu - **Description**: No description available - **Primary Language**: Ruby - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-10-14 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README = MigrationFu Rails gem / plugin for generating mysql foreign key constraints. == Install === as gem sudo gem install artemk-migration_fu === or plugin script/plugin install git://github.com/sleistner/migration_fu.git == Usage ----------------- ----------------- | users | | addresses | ----------------- ----------------- | id | | id | | username | <---- | user_id | | password | | street | ----------------- ----------------- [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}] [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}] see http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html arguments: from_table, to_table, options => { :name, :on_delete, :on_update } add_foreign_key(:addresses, :users, :name => 'fk_add_user') add_foreign_key(:addresses, :users, :on_delete => :cascade) add_foreign_key(:addresses, :users, :on_delete => :cascade, :on_update => :cascade) class CreateUsers < ActiveRecord::Migration def self.up create_table :users, :force => true do |t| t.string :username, :null => false t.string :password, :null => false end create_table :addresses, :force => true do |t| t.references :user t.string :street, :null => false end add_foreign_key(:addresses, :users, :on_delete => :cascade) end end