Refactor registrars

#765
This commit is contained in:
Artur Beljajev 2017-11-20 08:10:59 +02:00
parent cee51e1ac5
commit 0f6a47d73d
47 changed files with 644 additions and 640 deletions

View file

@ -0,0 +1,17 @@
class AddRegistrarsUniqueConstraints < ActiveRecord::Migration
def up
execute <<-SQL
ALTER TABLE registrars ADD CONSTRAINT unique_name UNIQUE (name);
ALTER TABLE registrars ADD CONSTRAINT unique_reference_no UNIQUE (reference_no);
ALTER TABLE registrars ADD CONSTRAINT unique_code UNIQUE (code);
SQL
end
def down
execute <<-SQL
ALTER TABLE registrars DROP CONSTRAINT unique_name;
ALTER TABLE registrars DROP CONSTRAINT unique_reference_no;
ALTER TABLE registrars DROP CONSTRAINT unique_code;
SQL
end
end

View file

@ -0,0 +1,6 @@
class RemoveRegistrarsIndexes < ActiveRecord::Migration
def change
remove_index :registrars, name: :index_registrars_on_code
remove_index :registrars, name: :index_registrars_on_legacy_id
end
end

View file

@ -0,0 +1,9 @@
class AddRegistrarsNotNullConstraints < ActiveRecord::Migration
def change
change_column_null :registrars, :name, false
change_column_null :registrars, :reg_no, false
change_column_null :registrars, :country_code, false
change_column_null :registrars, :email, false
change_column_null :registrars, :code, false
end
end