Skip to content

rafaelp/postgresql_migrations

Repository files navigation

Postgresql Migrations

DESCRIPTION

This gem implements "add_foreign_key" and "remove_foreign_key" for PostgreSQLAdapter.

REQUIREMENTS

  • activerecord
  • postgres

INSTALLATION

$ sudo gem sources -a http://gems.github.com (you only have to do this once)
$ sudo gem install rafaelp-postgresql_migrations

USAGE

Example 1

require 'postgresql_migrations'
class UserBelongsToAccount < ActiveRecord::Migration
  def self.up
    add_foreign_key :users, :account_id, :accounts, :id
  end

  def self.down
    remove_foreign_key :users, :account_id
  end
end

Example 2

require 'postgresql_migrations'
class UserBelongsToAccount < ActiveRecord::Migration
  def self.up
    add_foreign_key :users, :account_id, :accounts, :id, :match => 'simple', :on_delete => 'restrict', :on_update => 'cascade'
  end

  def self.down
    remove_foreign_key :users, :account_id
  end
end

LICENSE

Postgresql Migrations is released under the MIT License.

AUTHOR

Rafael Lima

Working at Myfreecomm

Blog: http://rafael.adm.br

Podcast: http://rafael.adm.br/voltandopracasa

Github: http://github.com/rafaelp

Twitter: http://twitter.com/rafaelp

Did you like?

Recommend me at Working With Rails

About

This gem implements add_foreign_key and remove_foreign_key for PostgreSQLAdapter.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages