Remove ofy support from HistoryEntry (#1823)

This PR removes all Ofy related cruft around `HistoryEntry` and its three subclasses in order to support dual-write to datastore and SQL. The class structure was refactored to take advantage of inheritance to reduce code duplication and improve clarity.

Note that for the embedded EPP resources, either their columns are all empty (for pre-3.0 entities imported into SQL), including their unique foreign key (domain name, host name, contact id) and the update timestamp; or they are filled as expected (for entities that were written since dual writing was implemented).

Therefore the check for foreign key column nullness in the various `@PostLoad` methods in the original code is an no-op as the EPP resource would have been loaded as null. In another word, there is no case where the update timestamp is null but other columns are not.

See the following query for the most recent entries in each table where the foreign key column or the update timestamp are null -- they are the same.

```
[I]postgres=> select MAX(history_modification_time) from "DomainHistory" where update_timestamp is null;
            max
----------------------------
 2021-09-27 15:56:52.502+00
(1 row)

[I]postgres=> select MAX(history_modification_time) from "DomainHistory" where domain_name is null;
            max
----------------------------
 2021-09-27 15:56:52.502+00
(1 row)

[I]postgres=> select MAX(history_modification_time) from "ContactHistory" where update_timestamp is null;
            max
----------------------------
 2021-09-27 15:56:04.311+00
(1 row)

[I]postgres=> select MAX(history_modification_time) from "ContactHistory" where contact_id is null;
            max
----------------------------
 2021-09-27 15:56:04.311+00
(1 row)

[I]postgres=> select MAX(history_modification_time) from "HostHistory" where update_timestamp is null;
            max
----------------------------
 2021-09-27 15:52:16.517+00
(1 row)

[I]postgres=> select MAX(history_modification_time) from "HostHistory" where host_name is null;
            max
----------------------------
 2021-09-27 15:52:16.517+00
(1 row)
```
This commit is contained in:
Lai Jiang 2022-11-01 21:17:20 -04:00 committed by GitHub
parent 5df9a2e4aa
commit ad4aa73328
88 changed files with 845 additions and 2213 deletions

View file

@ -22,8 +22,8 @@
discount_premiums boolean not null,
discount_years int4 not null,
domain_name text,
redemption_domain_history_id int8,
redemption_domain_repo_id text,
redemption_domain_history_id int8,
registration_behavior text not null,
renewal_price_behavior text not null,
token_status_transitions hstore,
@ -333,6 +333,9 @@
history_server_transaction_id text,
history_type text not null,
history_xml_bytes bytea,
history_other_registrar_id text,
history_period_unit text,
history_period_value int4,
admin_contact text,
auth_info_repo_id text,
auth_info_value text,
@ -384,9 +387,6 @@
last_epp_update_time timestamptz,
statuses text[],
update_timestamp timestamptz,
history_other_registrar_id text,
history_period_unit text,
history_period_value int4,
primary key (domain_repo_id, history_revision_id)
);