Class: InstallPgcrypto

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/pgcrypto/install/templates/migration.rb

Instance Method Summary collapse

Instance Method Details

#downObject



14
15
16
# File 'lib/generators/pgcrypto/install/templates/migration.rb', line 14

def down
  drop_table :pgcrypto_columns
end

#upObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/generators/pgcrypto/install/templates/migration.rb', line 2

def up
  create_table :pgcrypto_columns do |t|
    t.belongs_to :owner, :polymorphic => true
    t.string :owner_table, :limit => 32
    t.string :name, :limit => 32
    t.binary :value
  end
  add_index :pgcrypto_columns, [:owner_id, :owner_type, :name], :name => :pgcrypto_type_finder
  add_index :pgcrypto_columns, [:owner_id, :owner_table, :name], :name => :pgcrypto_table_finder
  execute("CREATE EXTENSION IF NOT EXISTS pgcrypto")
end