1
0
mirror of https://github.com/google/nomulus synced 2026-02-13 00:02:04 +00:00

Remove converter for CreateAutoTimestamp (#1429)

We can handle it the same way that we handle UpdateAutoTimestamp, where
we simply populate it in SQL if it doesn't exist. This has the following
benefits:

1. The converter is unnecessary code
2. We get non-null column definitions for free (overridden in
EppResource to allow null creation times so that legacy *History objects
can contain null in that field
3. More importantly, this allows us for proper SQL->DS replay. If the
field is filled out using a converter (as before this PR) then the field
is only actually filled out on transaction commit (rather than when the
write occurs within the transaction). This means that when we serialize
the Transaction object during the transaction (the data that gets
replayed to Datastore), we are crucially missing the creation time.

If the creation time is written on commit, we have to start a new
transaction to write the Transaction object, and it's an absolute
necessity that the record of the transaction be included in the
transaction itself so as to avoid situations where the transaction
succeeds but the record fails.

If the field is filled out in a @PrePersist method, crucially that
occurs on the object write itself (before transaction commit).
This commit is contained in:
gbrodman
2021-11-23 14:56:47 -05:00
committed by GitHub
parent 65c8769c68
commit 2d9e969f87
16 changed files with 118 additions and 182 deletions

View File

@@ -261,11 +261,11 @@ td.section {
</tr>
<tr>
<td class="property_name">generated on</td>
<td class="property_value">2021-09-14 16:11:21.688911</td>
<td class="property_value">2021-11-19 21:30:39.304221</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V102__add_indexes_to_domain_history_sub_tables.sql</td>
<td id="lastFlywayFile" class="property_value">V103__creation_time_not_null.sql</td>
</tr>
</tbody>
</table>
@@ -284,7 +284,7 @@ td.section {
generated on
</text>
<text text-anchor="start" x="4055.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2021-09-14 16:11:21.688911
2021-11-19 21:30:39.304221
</text>
<polygon fill="none" stroke="#888888" points="3968,-4 3968,-44 4233,-44 4233,-4 3968,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node">

View File

@@ -261,11 +261,11 @@ td.section {
</tr>
<tr>
<td class="property_name">generated on</td>
<td class="property_value">2021-09-14 16:11:19.580097</td>
<td class="property_value">2021-11-19 21:30:37.273092</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V102__add_indexes_to_domain_history_sub_tables.sql</td>
<td id="lastFlywayFile" class="property_value">V103__creation_time_not_null.sql</td>
</tr>
</tbody>
</table>
@@ -284,7 +284,7 @@ td.section {
generated on
</text>
<text text-anchor="start" x="4755.52" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2021-09-14 16:11:19.580097
2021-11-19 21:30:37.273092
</text>
<polygon fill="none" stroke="#888888" points="4668.02,-4 4668.02,-44 4933.02,-44 4933.02,-4 4668.02,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node">
@@ -1365,7 +1365,7 @@ td.section {
<text text-anchor="start" x="311" y="-2137.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text>
<text text-anchor="start" x="319" y="-2137.3" font-family="Helvetica,sans-Serif" font-size="14.00">
timestamptz
timestamptz not null
</text>
<text text-anchor="start" x="11" y="-2118.3" font-family="Helvetica,sans-Serif" font-size="14.00">
drive_folder_id
@@ -12184,7 +12184,7 @@ td.section {
<tr>
<td class="spacer"></td>
<td class="minwidth">creation_time</td>
<td class="minwidth">timestamptz</td>
<td class="minwidth">timestamptz not null</td>
</tr>
<tr>
<td class="spacer"></td>

View File

@@ -100,3 +100,4 @@ V99__drop_kms_secret_table.sql
V100__database_migration_schedule.sql
V101__domain_add_dns_refresh_request_time.sql
V102__add_indexes_to_domain_history_sub_tables.sql
V103__creation_time_not_null.sql

View File

@@ -0,0 +1,15 @@
-- Copyright 2021 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 "Registrar" ALTER COLUMN creation_time SET NOT NULL;

View File

@@ -572,7 +572,7 @@
client_certificate text,
client_certificate_hash text,
contacts_require_syncing boolean not null,
creation_time timestamptz,
creation_time timestamptz not null,
drive_folder_id text,
email_address text,
failover_client_certificate text,

View File

@@ -763,7 +763,7 @@ CREATE TABLE public."Registrar" (
client_certificate text,
client_certificate_hash text,
contacts_require_syncing boolean NOT NULL,
creation_time timestamp with time zone,
creation_time timestamp with time zone NOT NULL,
drive_folder_id text,
email_address text,
failover_client_certificate text,