From c675512b22a566ba0b5d9ef7690c92b747fa5cde Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Sat, 31 Mar 2018 23:31:40 +0300 Subject: [PATCH] Change `domains.valid_to` DB column to NOT NULL #800 --- app/models/whois_record.rb | 2 +- app/views/epp/domains/create.xml.builder | 2 +- app/views/epp/domains/info.xml.builder | 2 +- app/views/epp/domains/partials/_transfer.xml.builder | 2 +- app/views/epp/domains/renew.xml.builder | 2 +- .../20180331200125_change_domains_valid_to_to_not_null.rb | 5 +++++ db/structure.sql | 4 +++- spec/factories/domain.rb | 1 + 8 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index bd16e0c99..45cff4036 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -48,7 +48,7 @@ class WhoisRecord < ActiveRecord::Base h[:status] = domain.statuses.map { |x| status_map[x] || x } h[:registered] = domain.registered_at.try(:to_s, :iso8601) h[:changed] = domain.updated_at.try(:to_s, :iso8601) - h[:expire] = domain.valid_to.try(:to_date).try(:to_s) + h[:expire] = domain.valid_to.to_date.to_s h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s) h[:delete] = [domain.delete_at, domain.force_delete_at].compact.min.try(:to_date).try(:to_s) diff --git a/app/views/epp/domains/create.xml.builder b/app/views/epp/domains/create.xml.builder index 213a2aa8f..2293f5657 100644 --- a/app/views/epp/domains/create.xml.builder +++ b/app/views/epp/domains/create.xml.builder @@ -8,7 +8,7 @@ xml.epp_head do xml.tag!('domain:creData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do xml.tag!('domain:name', @domain.name) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) + xml.tag!('domain:exDate', @domain.valid_to.iso8601) end end diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 8bf169acd..2d10f8baf 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -48,7 +48,7 @@ xml.epp_head do xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) end - xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) + xml.tag!('domain:exDate', @domain.valid_to.iso8601) # TODO Make domain transferrable #xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at diff --git a/app/views/epp/domains/partials/_transfer.xml.builder b/app/views/epp/domains/partials/_transfer.xml.builder index 151af28b3..bfcc7db94 100644 --- a/app/views/epp/domains/partials/_transfer.xml.builder +++ b/app/views/epp/domains/partials/_transfer.xml.builder @@ -5,5 +5,5 @@ builder.tag!('domain:trnData', 'xmlns:domain' => 'https://epp.tld.ee/schema/doma builder.tag!('domain:reDate', dt.transfer_requested_at.try(:iso8601)) builder.tag!('domain:acID', dt.old_registrar.code) builder.tag!('domain:acDate', dt.transferred_at.try(:iso8601) || dt.wait_until.try(:iso8601)) - builder.tag!('domain:exDate', dt.domain_valid_to.try(:iso8601)) + builder.tag!('domain:exDate', dt.domain_valid_to.iso8601) end diff --git a/app/views/epp/domains/renew.xml.builder b/app/views/epp/domains/renew.xml.builder index 5d03c7128..e407ff0e7 100644 --- a/app/views/epp/domains/renew.xml.builder +++ b/app/views/epp/domains/renew.xml.builder @@ -7,7 +7,7 @@ xml.epp_head do xml.resData do xml.tag!('domain:renData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do xml.tag!('domain:name', @domain[:name]) - xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) + xml.tag!('domain:exDate', @domain.valid_to.iso8601) end end diff --git a/db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb b/db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb new file mode 100644 index 000000000..049b08806 --- /dev/null +++ b/db/migrate/20180331200125_change_domains_valid_to_to_not_null.rb @@ -0,0 +1,5 @@ +class ChangeDomainsValidToToNotNull < ActiveRecord::Migration + def change + change_column_null :domains, :valid_to, false + end +end diff --git a/db/structure.sql b/db/structure.sql index 374b17b5b..2e662f6f5 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -873,7 +873,7 @@ CREATE TABLE domains ( registered_at timestamp without time zone, status character varying, valid_from timestamp without time zone, - valid_to timestamp without time zone, + valid_to timestamp without time zone NOT NULL, registrant_id integer NOT NULL, transfer_code character varying NOT NULL, created_at timestamp without time zone, @@ -4695,3 +4695,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180309053921'); INSERT INTO schema_migrations (version) VALUES ('20180309054510'); +INSERT INTO schema_migrations (version) VALUES ('20180331200125'); + diff --git a/spec/factories/domain.rb b/spec/factories/domain.rb index fc4d3a97b..8abac339c 100644 --- a/spec/factories/domain.rb +++ b/spec/factories/domain.rb @@ -3,6 +3,7 @@ FactoryBot.define do sequence(:name) { |n| "test#{n}.com" } period 1 period_unit 'y' # Year + valid_to Time.zone.parse('2010-07-05') registrar registrant