Class: EnforceAddressUniquenessInWorkspaceInHosts

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb

Overview

Changes index on address so it scoped to workspace_id and is unique to match the validation in Mdm::Host on Mdm::Host#address.

Constant Summary collapse

TABLE_NAME =
:hosts

Instance Method Summary collapse

Instance Method Details

#downObject

Restores old index on address



7
8
9
10
11
12
13
# File 'db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb', line 7

def down
  change_table TABLE_NAME do |t|
    t.remove_index [:workspace_id, :address]

    t.index :address
  end
end

#upObject

Make index on address scope to workspace_id and be unique



16
17
18
19
20
21
22
# File 'db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb', line 16

def up
  change_table TABLE_NAME do |t|
    t.remove_index :address

    t.index [:workspace_id, :address], :unique => true
  end
end