diff --git a/config/nom_build.py b/config/nom_build.py index 47cf1a081..7cce7209e 100644 --- a/config/nom_build.py +++ b/config/nom_build.py @@ -19,7 +19,7 @@ import argparse import dataclasses import io import os -import shutil +import re import subprocess import sys from typing import List, Union @@ -285,11 +285,17 @@ def do_pseudo_task(task: str) -> None: print('\033[33mWARNING:\033[0m Ignore the above failure, it is ' 'expected.') - # Copy the new schema into place. - shutil.copy(f'{root}/db/build/resources/test/testcontainer/' - 'mount/dump.txt', - f'{root}/db/src/main/resources/sql/schema/' - 'nomulus.golden.sql') + # Copy the new schema into place, stripping psql \restrict and + # \unrestrict meta-commands emitted by pg_dump 17.6+. + dump_path = (f'{root}/db/build/resources/test/testcontainer/' + 'mount/dump.txt') + golden_path = (f'{root}/db/src/main/resources/sql/schema/' + 'nomulus.golden.sql') + with open(dump_path, 'r', encoding='utf-8') as src: + content = re.sub( + r'^\\(un)?restrict .*\n\n?', '', src.read(), flags=re.MULTILINE) + with open(golden_path, 'w', encoding='utf-8') as dst: + dst.write(content) # Rerun :db:test and regenerate the ER diagram (at "warning" log # level so it doesn't generate pages of messaging) diff --git a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html index 8b92a34f4..0d470d4e1 100644 --- a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html @@ -261,11 +261,11 @@ td.section { generated on - 2026-08-27 21:08:38 + 2026-09-25 20:40:54 last flyway file - V230__registrar_drop_xap_enabled_default.sql + V231__defer_console_update_history_user_fk.sql @@ -273,7 +273,7 @@ td.section {

 

- SchemaCrawler_Diagram generated by SchemaCrawler 17.12.2 generated on 2026-08-27 21:08:38 + SchemaCrawler_Diagram generated by SchemaCrawler 17.12.2 generated on 2026-09-25 20:40:54 allocationtoken_a08ccbef public."AllocationToken" [table] token text not null domain_name text redemption_domain_repo_id text token_type text diff --git a/db/src/main/resources/sql/er_diagram/full_er_diagram.html b/db/src/main/resources/sql/er_diagram/full_er_diagram.html index 476274fce..ebf1cdec4 100644 --- a/db/src/main/resources/sql/er_diagram/full_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/full_er_diagram.html @@ -261,11 +261,11 @@ td.section {
generated on - 2026-08-27 21:08:36 + 2026-09-25 20:40:53
last flyway file - V230__registrar_drop_xap_enabled_default.sql + V231__defer_console_update_history_user_fk.sql
@@ -273,7 +273,7 @@ td.section {

 

- SchemaCrawler_Diagram generated by SchemaCrawler 17.12.2 generated on 2026-08-27 21:08:36 + SchemaCrawler_Diagram generated by SchemaCrawler 17.12.2 generated on 2026-09-25 20:40:53 allocationtoken_a08ccbef public."AllocationToken" [table] token text not null update_timestamp timestamptz allowed_registrar_ids _text allowed_tlds _text creation_time timestamptz not null discount_fraction float8(17, 17) not null discount_premiums bool not null discount_years int4 not null domain_name text redemption_domain_repo_id text token_status_transitions hstore token_type text redemption_domain_history_id int8 renewal_price_behavior text not null registration_behavior text not null allowed_epp_actions _text renewal_price_amount numeric(19, 2) renewal_price_currency text discount_price_amount numeric(19, 2) discount_price_currency text diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index 5f24ecb32..252083a7e 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -228,3 +228,4 @@ V227__domainhistory_repo_id_mod_time_idx.sql V228__hosthistory_repo_id_mod_time_idx.sql V229__tld_drop_xap_transitions_default.sql V230__registrar_drop_xap_enabled_default.sql +V231__defer_console_update_history_user_fk.sql diff --git a/db/src/main/resources/sql/flyway/V231__defer_console_update_history_user_fk.sql b/db/src/main/resources/sql/flyway/V231__defer_console_update_history_user_fk.sql new file mode 100644 index 000000000..ce01133bf --- /dev/null +++ b/db/src/main/resources/sql/flyway/V231__defer_console_update_history_user_fk.sql @@ -0,0 +1,21 @@ +-- Copyright 2026 The Nomulus Authors. All Rights Reserved. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +ALTER TABLE "ConsoleUpdateHistory" + DROP CONSTRAINT fk_console_update_history_acting_user; +ALTER TABLE "ConsoleUpdateHistory" + ADD CONSTRAINT fk_console_update_history_acting_user + FOREIGN KEY (acting_user) + REFERENCES "User"(email_address) + DEFERRABLE INITIALLY DEFERRED; diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index 2a73e40cb..011c559ea 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -2,8 +2,8 @@ -- PostgreSQL database dump -- --- Dumped from database version 17.4 --- Dumped by pg_dump version 17.4 +-- Dumped from database version 17.10 +-- Dumped by pg_dump version 17.10 SET statement_timeout = 0; SET lock_timeout = 0; @@ -2740,7 +2740,7 @@ ALTER TABLE ONLY public."BillingRecurrence" -- ALTER TABLE ONLY public."ConsoleUpdateHistory" - ADD CONSTRAINT fk_console_update_history_acting_user FOREIGN KEY (acting_user) REFERENCES public."User"(email_address); + ADD CONSTRAINT fk_console_update_history_acting_user FOREIGN KEY (acting_user) REFERENCES public."User"(email_address) DEFERRABLE INITIALLY DEFERRED; --