MonoForge

spejman / simplified_fk

simplified_fk

Public

Add foreign keys to your database. Only for PostgreSQL & MySQL.

11 filesupdated Jun 18, 2026

README

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