# 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, :accounts, :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](myfreecomm.com.br)

Blog: [rafael.adm.br](http://rafael.adm.br)

Podcast: [rafael.adm.br/voltandopracasa](http://rafael.adm.br/voltandopracasa)

Github: [github.com/rafaelp](http://github.com/rafaelp)

Twitter: [twitter.com/rafaelp](http://twitter.com/rafaelp)

### Did you like?

[Recommend me at Working With Rails](workingwithrails.com/recommendation/new/person/14248-rafael-lima)