Merge pull request #1417 from internetee/add-contacts-name-constraint

Change `contacts.name` database column to NOT NULL
This commit is contained in:
Timo Võhmar 2019-12-12 12:30:18 +02:00 committed by GitHub
commit 86f5c87d04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 8 deletions

View file

@ -288,7 +288,7 @@ class Contact < ApplicationRecord
end end
def to_s def to_s
name || '[no name]' name
end end
def validate_html def validate_html

View file

@ -0,0 +1,5 @@
class ChangeContactsNameToNotNull < ActiveRecord::Migration
def change
change_column_null :contacts, :name, false
end
end

View file

@ -613,7 +613,7 @@ CREATE TABLE public.contacts (
ident character varying, ident character varying,
ident_type character varying, ident_type character varying,
auth_info character varying NOT NULL, auth_info character varying NOT NULL,
name character varying, name character varying NOT NULL,
org_name character varying, org_name character varying,
registrar_id integer NOT NULL, registrar_id integer NOT NULL,
creator_str character varying, creator_str character varying,
@ -4280,6 +4280,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20180613030330'), ('20180613030330'),
('20180613045614'), ('20180613045614'),
('20180713154915'), ('20180713154915'),
('20180801114403'),
('20180808064402'), ('20180808064402'),
('20180816123540'), ('20180816123540'),
('20180823161237'), ('20180823161237'),

View file

@ -18,8 +18,8 @@ class ContactVersionsTest < ApplicationSystemTestCase
def create_contact_with_history def create_contact_with_history
sql = <<-SQL.squish sql = <<-SQL.squish
INSERT INTO contacts (id, code, email, auth_info, registrar_id) INSERT INTO contacts (id, name, code, email, auth_info, registrar_id)
VALUES (75, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', #{@registrar.id}); VALUES (75, 'test_name', 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', #{@registrar.id});
INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object, INSERT INTO log_contacts (item_type, item_id, event, whodunnit, object,
object_changes, created_at, session, children, ident_updated_at, uuid) object_changes, created_at, session, children, ident_updated_at, uuid)

View file

@ -18,8 +18,8 @@ class DomainVersionsTest < ApplicationSystemTestCase
def create_domain_with_history def create_domain_with_history
sql = <<-SQL.squish sql = <<-SQL.squish
INSERT INTO contacts (id, code, email, auth_info, registrar_id) INSERT INTO contacts (id, name, code, email, auth_info, registrar_id)
VALUES (54, 'test_code', 'test@inbox.test', '8b4d462aa04194ca78840a', #{@registrar.id}); VALUES (54, 'test_code', 'test_name', 'test@inbox.test', '8b4d462aa04194ca78840a', #{@registrar.id});
INSERT INTO domains (id, name, name_puny, name_dirty, registrar_id, valid_to, registrant_id, INSERT INTO domains (id, name, name_puny, name_dirty, registrar_id, valid_to, registrant_id,
transfer_code) transfer_code)