spejman / simplified_fk
simplified_fk
PublicAdd foreign keys to your database. Only for PostgreSQL & MySQL.
11 filesupdated Jun 18, 2026
files8Download
./generatorsJun 17, 2026./libJun 17, 2026./testJun 17, 2026.gitignoreJun 17, 2026init.rbJun 17, 2026MIT-LICENSEJun 17, 2026RakefileJun 17, 2026READMEJun 18, 2026README
Simplified Fk
Because adding foreign keys to your database should be easy.
Adding a foreign key:
add_foreign_key :from_table, :from_column, :to_table
Removing a foreign key:
remove_foreign_key :from_table, :from_column
Note: Only works on MySQL and PostgreSQL.
TODO
[ ] Add a task to suggest foreign keys.
Example
class AddForeignKeyOnArticles < ActiveRecord::Migration
def self.up
add_foreign_key :articles, :user_id, :users
end
def self.down
remove_foreign_key :articles, :user_id
end
end
Copyright (c) 2008 Francesc Esplugas Marti, released under the MIT license