Make some columns nullable in History tables (#873)

* Make some columns nullable in History tables

xmlBytes is made nullable in all history tables since changes performed
by backend actions would not have it. In addition, epp requests are not saved to
ContactHistory since data may contain PII.

requestedByRegistrar in all history tables are made nullable. This
property is set from metadata in epp requests. Null means not provided.
This commit is contained in:
Weimin Yu 2020-11-13 15:25:54 -05:00 committed by GitHub
parent 31c16e8369
commit fe8f4cc4ac
7 changed files with 63 additions and 33 deletions

View file

@ -137,8 +137,12 @@ public class HistoryEntry extends ImmutableObject implements Buildable, Datastor
@Transient // domain-specific @Transient // domain-specific
Period period; Period period;
/** The actual EPP xml of the command, stored as bytes to be agnostic of encoding. */ /**
@Column(nullable = false, name = "historyXmlBytes") * The actual EPP xml of the command, stored as bytes to be agnostic of encoding.
*
* <p>Changes performed by backend actions would not have EPP requests to store.
*/
@Column(name = "historyXmlBytes")
byte[] xmlBytes; byte[] xmlBytes;
/** The time the command occurred, represented by the ofy transaction time. */ /** The time the command occurred, represented by the ofy transaction time. */
@ -182,7 +186,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, Datastor
String reason; String reason;
/** Whether this change was requested by a registrar. */ /** Whether this change was requested by a registrar. */
@Column(nullable = false, name = "historyRequestedByRegistrar") @Column(name = "historyRequestedByRegistrar")
Boolean requestedByRegistrar; Boolean requestedByRegistrar;
/** /**

View file

@ -261,11 +261,11 @@ td.section {
</tr> </tr>
<tr> <tr>
<td class="property_name">generated on</td> <td class="property_name">generated on</td>
<td class="property_value">2020-11-12 02:22:52.212444</td> <td class="property_value">2020-11-13 19:34:54.398919</td>
</tr> </tr>
<tr> <tr>
<td class="property_name">last flyway file</td> <td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V75__add_grace_period_history.sql</td> <td id="lastFlywayFile" class="property_value">V76__change_history_nullability.sql</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -284,7 +284,7 @@ td.section {
generated on generated on
</text> </text>
<text text-anchor="start" x="5830.94" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="5830.94" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2020-11-12 02:22:52.212444 2020-11-13 19:34:54.398919
</text> </text>
<polygon fill="none" stroke="#888888" points="5743.44,-4 5743.44,-44 6008.44,-44 6008.44,-4 5743.44,-4" /> <!-- allocationtoken_a08ccbef --> <polygon fill="none" stroke="#888888" points="5743.44,-4 5743.44,-44 6008.44,-44 6008.44,-4 5743.44,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node"> <g id="node1" class="node">

View file

@ -261,11 +261,11 @@ td.section {
</tr> </tr>
<tr> <tr>
<td class="property_name">generated on</td> <td class="property_name">generated on</td>
<td class="property_value">2020-11-12 02:22:50.323783</td> <td class="property_value">2020-11-13 19:34:52.404634</td>
</tr> </tr>
<tr> <tr>
<td class="property_name">last flyway file</td> <td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V75__add_grace_period_history.sql</td> <td id="lastFlywayFile" class="property_value">V76__change_history_nullability.sql</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -284,7 +284,7 @@ td.section {
generated on generated on
</text> </text>
<text text-anchor="start" x="6501.68" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="6501.68" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">
2020-11-12 02:22:50.323783 2020-11-13 19:34:52.404634
</text> </text>
<polygon fill="none" stroke="#888888" points="6414.18,-4 6414.18,-44 6679.18,-44 6679.18,-4 6414.18,-4" /> <!-- allocationtoken_a08ccbef --> <polygon fill="none" stroke="#888888" points="6414.18,-4 6414.18,-44 6679.18,-44 6679.18,-4 6414.18,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node"> <g id="node1" class="node">
@ -701,7 +701,7 @@ td.section {
<text text-anchor="start" x="4457" y="-3829.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4457" y="-3829.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text> </text>
<text text-anchor="start" x="4465" y="-3829.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4465" y="-3829.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bool not null bool
</text> </text>
<text text-anchor="start" x="4179" y="-3810.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4179" y="-3810.3" font-family="Helvetica,sans-Serif" font-size="14.00">
history_client_transaction_id history_client_transaction_id
@ -733,7 +733,7 @@ td.section {
<text text-anchor="start" x="4457" y="-3753.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4457" y="-3753.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text> </text>
<text text-anchor="start" x="4465" y="-3753.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4465" y="-3753.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bytea not null bytea
</text> </text>
<text text-anchor="start" x="4179" y="-3734.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="4179" y="-3734.3" font-family="Helvetica,sans-Serif" font-size="14.00">
admin_contact admin_contact
@ -3789,7 +3789,7 @@ td.section {
<text text-anchor="start" x="1517.5" y="-2523.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1517.5" y="-2523.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text> </text>
<text text-anchor="start" x="1525.5" y="-2523.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1525.5" y="-2523.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bool not null bool
</text> </text>
<text text-anchor="start" x="1306.5" y="-2504.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1306.5" y="-2504.3" font-family="Helvetica,sans-Serif" font-size="14.00">
history_client_transaction_id history_client_transaction_id
@ -3821,7 +3821,7 @@ td.section {
<text text-anchor="start" x="1517.5" y="-2447.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1517.5" y="-2447.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text> </text>
<text text-anchor="start" x="1525.5" y="-2447.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1525.5" y="-2447.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bytea not null bytea
</text> </text>
<text text-anchor="start" x="1306.5" y="-2428.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1306.5" y="-2428.3" font-family="Helvetica,sans-Serif" font-size="14.00">
auth_info_repo_id auth_info_repo_id
@ -4562,7 +4562,7 @@ td.section {
<text text-anchor="start" x="1507.5" y="-1189.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1507.5" y="-1189.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text> </text>
<text text-anchor="start" x="1515.5" y="-1189.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1515.5" y="-1189.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bool not null bool
</text> </text>
<text text-anchor="start" x="1316.5" y="-1170.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1316.5" y="-1170.3" font-family="Helvetica,sans-Serif" font-size="14.00">
history_client_transaction_id history_client_transaction_id
@ -4594,7 +4594,7 @@ td.section {
<text text-anchor="start" x="1507.5" y="-1113.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1507.5" y="-1113.3" font-family="Helvetica,sans-Serif" font-size="14.00">
</text> </text>
<text text-anchor="start" x="1515.5" y="-1113.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1515.5" y="-1113.3" font-family="Helvetica,sans-Serif" font-size="14.00">
bytea not null bytea
</text> </text>
<text text-anchor="start" x="1316.5" y="-1094.3" font-family="Helvetica,sans-Serif" font-size="14.00"> <text text-anchor="start" x="1316.5" y="-1094.3" font-family="Helvetica,sans-Serif" font-size="14.00">
host_name host_name
@ -7983,7 +7983,7 @@ td.section {
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
<td class="minwidth">history_requested_by_registrar</td> <td class="minwidth">history_requested_by_registrar</td>
<td class="minwidth">bool not null</td> <td class="minwidth">bool</td>
</tr> </tr>
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
@ -8003,7 +8003,7 @@ td.section {
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
<td class="minwidth">history_xml_bytes</td> <td class="minwidth">history_xml_bytes</td>
<td class="minwidth">bytea not null</td> <td class="minwidth">bytea</td>
</tr> </tr>
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
@ -9425,7 +9425,7 @@ td.section {
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
<td class="minwidth">history_requested_by_registrar</td> <td class="minwidth">history_requested_by_registrar</td>
<td class="minwidth">bool not null</td> <td class="minwidth">bool</td>
</tr> </tr>
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
@ -9445,7 +9445,7 @@ td.section {
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
<td class="minwidth">history_xml_bytes</td> <td class="minwidth">history_xml_bytes</td>
<td class="minwidth">bytea not null</td> <td class="minwidth">bytea</td>
</tr> </tr>
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
@ -10717,7 +10717,7 @@ td.section {
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
<td class="minwidth">history_requested_by_registrar</td> <td class="minwidth">history_requested_by_registrar</td>
<td class="minwidth">bool not null</td> <td class="minwidth">bool</td>
</tr> </tr>
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
@ -10737,7 +10737,7 @@ td.section {
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>
<td class="minwidth">history_xml_bytes</td> <td class="minwidth">history_xml_bytes</td>
<td class="minwidth">bytea not null</td> <td class="minwidth">bytea</td>
</tr> </tr>
<tr> <tr>
<td class="spacer"></td> <td class="spacer"></td>

View file

@ -73,3 +73,4 @@ V72__add_missing_foreign_keys.sql
V73__singleton_entities.sql V73__singleton_entities.sql
V74__sql_replay_checkpoint.sql V74__sql_replay_checkpoint.sql
V75__add_grace_period_history.sql V75__add_grace_period_history.sql
V76__change_history_nullability.sql

View file

@ -0,0 +1,25 @@
-- Copyright 2020 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 "ContactHistory"
ALTER column history_xml_bytes DROP NOT NULL,
ALTER column history_requested_by_registrar DROP NOT NULL;
ALTER table "DomainHistory"
ALTER column history_xml_bytes DROP NOT NULL,
ALTER column history_requested_by_registrar DROP NOT NULL;
ALTER table "HostHistory"
ALTER column history_xml_bytes DROP NOT NULL,
ALTER column history_requested_by_registrar DROP NOT NULL;

View file

@ -156,11 +156,11 @@
history_registrar_id text, history_registrar_id text,
history_modification_time timestamptz not null, history_modification_time timestamptz not null,
history_reason text, history_reason text,
history_requested_by_registrar boolean not null, history_requested_by_registrar boolean,
history_client_transaction_id text, history_client_transaction_id text,
history_server_transaction_id text, history_server_transaction_id text,
history_type text not null, history_type text not null,
history_xml_bytes bytea not null, history_xml_bytes bytea,
auth_info_repo_id text, auth_info_repo_id text,
auth_info_value text, auth_info_value text,
contact_id text, contact_id text,
@ -309,11 +309,11 @@
history_registrar_id text, history_registrar_id text,
history_modification_time timestamptz not null, history_modification_time timestamptz not null,
history_reason text, history_reason text,
history_requested_by_registrar boolean not null, history_requested_by_registrar boolean,
history_client_transaction_id text, history_client_transaction_id text,
history_server_transaction_id text, history_server_transaction_id text,
history_type text not null, history_type text not null,
history_xml_bytes bytea not null, history_xml_bytes bytea,
admin_contact text, admin_contact text,
auth_info_repo_id text, auth_info_repo_id text,
auth_info_value text, auth_info_value text,
@ -446,11 +446,11 @@
history_registrar_id text, history_registrar_id text,
history_modification_time timestamptz not null, history_modification_time timestamptz not null,
history_reason text, history_reason text,
history_requested_by_registrar boolean not null, history_requested_by_registrar boolean,
history_client_transaction_id text, history_client_transaction_id text,
history_server_transaction_id text, history_server_transaction_id text,
history_type text not null, history_type text not null,
history_xml_bytes bytea not null, history_xml_bytes bytea,
host_name text, host_name text,
inet_addresses text[], inet_addresses text[],
last_superordinate_change timestamptz, last_superordinate_change timestamptz,

View file

@ -228,11 +228,11 @@ CREATE TABLE public."ContactHistory" (
history_registrar_id text, history_registrar_id text,
history_modification_time timestamp with time zone NOT NULL, history_modification_time timestamp with time zone NOT NULL,
history_reason text, history_reason text,
history_requested_by_registrar boolean NOT NULL, history_requested_by_registrar boolean,
history_client_transaction_id text, history_client_transaction_id text,
history_server_transaction_id text, history_server_transaction_id text,
history_type text NOT NULL, history_type text NOT NULL,
history_xml_bytes bytea NOT NULL, history_xml_bytes bytea,
auth_info_repo_id text, auth_info_repo_id text,
auth_info_value text, auth_info_value text,
contact_id text, contact_id text,
@ -401,11 +401,11 @@ CREATE TABLE public."DomainHistory" (
history_registrar_id text, history_registrar_id text,
history_modification_time timestamp with time zone NOT NULL, history_modification_time timestamp with time zone NOT NULL,
history_reason text, history_reason text,
history_requested_by_registrar boolean NOT NULL, history_requested_by_registrar boolean,
history_client_transaction_id text, history_client_transaction_id text,
history_server_transaction_id text, history_server_transaction_id text,
history_type text NOT NULL, history_type text NOT NULL,
history_xml_bytes bytea NOT NULL, history_xml_bytes bytea,
admin_contact text, admin_contact text,
auth_info_repo_id text, auth_info_repo_id text,
auth_info_value text, auth_info_value text,
@ -587,11 +587,11 @@ CREATE TABLE public."HostHistory" (
history_registrar_id text NOT NULL, history_registrar_id text NOT NULL,
history_modification_time timestamp with time zone NOT NULL, history_modification_time timestamp with time zone NOT NULL,
history_reason text, history_reason text,
history_requested_by_registrar boolean NOT NULL, history_requested_by_registrar boolean,
history_client_transaction_id text, history_client_transaction_id text,
history_server_transaction_id text, history_server_transaction_id text,
history_type text NOT NULL, history_type text NOT NULL,
history_xml_bytes bytea NOT NULL, history_xml_bytes bytea,
host_name text, host_name text,
inet_addresses text[], inet_addresses text[],
last_superordinate_change timestamp with time zone, last_superordinate_change timestamp with time zone,