Sha256: 6327a1f01a2ddcf0ff10082a4f75ad64433645c7c16eef23e24b763b81c1c069

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

class RemoveUniquenessForRegistrationNumber < ActiveRecord::Migration
  def up
    remove_index "lines", name: "lines_registration_number_key" if index_exists?(:lines, :registration_number, name: "lines_registration_number_key")
    add_index "lines", ["registration_number"], :name => "lines_registration_number_key"

    remove_index "companies", name: "companies_registration_number_key" if index_exists?(:companies, :registration_number, name: "companies_registration_number_key")
    add_index "companies", ["registration_number"], :name => "companies_registration_number_key"

    remove_index "networks", name: "networks_registration_number_key" if index_exists?(:networks, :registration_number, name: "networks_registration_number_key")
    add_index "networks", ["registration_number"], :name => "networks_registration_number_key"
  end
  def down
    remove_index "lines", name: "lines_registration_number_key" if index_exists?(:lines, :registration_number, name: "lines_registration_number_key")
    add_index "lines", ["registration_number"], :name => "lines_registration_number_key", :unique => true

    remove_index "companies", name: "companies_registration_number_key" if index_exists?(:companies, :registration_number, name: "companies_registration_number_key")
    add_index "companies", ["registration_number"], :name => "companies_registration_number_key", :unique => true

    remove_index "networks", name: "networks_registration_number_key" if index_exists?(:networks, :registration_number, name: "networks_registration_number_key")
    add_index "networks", ["registration_number"], :name => "networks_registration_number_key", :unique => true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ninoxe-1.2.3 db/migrate/20150630135517_remove_uniqueness_for_registration_number.rb
ninoxe-1.2.2 db/migrate/20150630135517_remove_uniqueness_for_registration_number.rb
ninoxe-1.2.1 db/migrate/20150630135517_remove_uniqueness_for_registration_number.rb