Merge branch 'master' into registry-791

# Conflicts:
#	db/structure.sql
This commit is contained in:
Artur Beljajev 2018-06-21 17:38:38 +03:00
commit f299241b28
33 changed files with 343 additions and 344 deletions

View file

@ -0,0 +1,5 @@
class EnablePgcryptoExt < ActiveRecord::Migration
def change
enable_extension 'pgcrypto'
end
end

View file

@ -0,0 +1,5 @@
class AddUuidToContacts < ActiveRecord::Migration
def change
add_column :contacts, :uuid, :uuid, default: 'gen_random_uuid()'
end
end

View file

@ -0,0 +1,5 @@
class AddUuidToDomains < ActiveRecord::Migration
def change
add_column :domains, :uuid, :uuid, default: 'gen_random_uuid()'
end
end

View file

@ -0,0 +1,6 @@
class ChangeContactsAndDomainsUuidToNotNull < ActiveRecord::Migration
def change
change_column_null :contacts, :uuid, false
change_column_null :domains, :uuid, false
end
end

View file

@ -0,0 +1,16 @@
# Unique constraint is needed to prevent accidental duplicate values in fixtures to appear in DB
class AddContactsAndDomainsUuidUniqConstraint < ActiveRecord::Migration
def up
execute <<-SQL
ALTER TABLE contacts ADD CONSTRAINT uniq_contact_uuid UNIQUE (uuid);
ALTER TABLE domains ADD CONSTRAINT uniq_domain_uuid UNIQUE (uuid);
SQL
end
def down
execute <<-SQL
ALTER TABLE contacts DROP CONSTRAINT uniq_contact_uuid;
ALTER TABLE domains DROP CONSTRAINT uniq_domain_uuid;
SQL
end
end