From f36d22f4b1fb1b867aa4566f6eb9bacd259d95bf Mon Sep 17 00:00:00 2001 From: gbrodman Date: Wed, 8 Feb 2023 16:10:34 -0500 Subject: [PATCH] Allow null GAIA IDs for User objects (#1933) We were under the mistaken impression before that there was a reliable way to, out-of-band, get a GAIA ID for a particular email address. Unfortunately, that isn't the case (at least, not in a scalable way or one that support agents could use). As a result, we have to allow null GAIA IDs in the database. When we (or the support team) create new users, we will only specify the email address and not the GAIA ID. Then, when the user logs in for the first time, we will have the GAIA ID from the provided ID token, and we can populate it then. --- .../sql/er_diagram/brief_er_diagram.html | 10 +++++----- .../sql/er_diagram/full_er_diagram.html | 20 +++++++++---------- db/src/main/resources/sql/flyway.txt | 1 + .../sql/flyway/V135__null_gaia_id_user.sql | 15 ++++++++++++++ .../resources/sql/schema/nomulus.golden.sql | 2 +- 5 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V135__null_gaia_id_user.sql 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 8a0605836..c6cf3ad73 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 - 2023-01-20 19:50:48.623695 + 2023-02-08 17:40:28.930421 last flyway file - V134__drop_not_null_request_id_lock_table.sql + V135__null_gaia_id_user.sql @@ -284,7 +284,7 @@ td.section { generated on - 2023-01-20 19:50:48.623695 + 2023-02-08 17:40:28.930421 @@ -3220,7 +3220,7 @@ td.section { - text not null + text @@ -7067,7 +7067,7 @@ td.section { gaia_id - text not null + 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 942297618..c252585e6 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 - 2023-01-20 19:50:45.218406 + 2023-02-08 17:40:26.84563 last flyway file - V134__drop_not_null_request_id_lock_table.sql + V135__null_gaia_id_user.sql @@ -274,19 +274,19 @@ td.section { SchemaCrawler_Diagram - + generated by - + SchemaCrawler 16.10.1 - + generated on - - 2023-01-20 19:50:45.218406 + + 2023-02-08 17:40:26.84563 - + allocationtoken_a08ccbef @@ -6564,7 +6564,7 @@ td.section { - text not null + text registry_lock_password_hash @@ -14351,7 +14351,7 @@ td.section {
gaia_id - text not null + text
diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index 636a996d5..67c92dd47 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -132,3 +132,4 @@ V131__add_default_promo_tokens_to_registry.sql V132__drop_gae_user_id_from_registrar_poc.sql V133__add_pull_queue_replace_columns.sql V134__drop_not_null_request_id_lock_table.sql +V135__null_gaia_id_user.sql diff --git a/db/src/main/resources/sql/flyway/V135__null_gaia_id_user.sql b/db/src/main/resources/sql/flyway/V135__null_gaia_id_user.sql new file mode 100644 index 000000000..984c172e7 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V135__null_gaia_id_user.sql @@ -0,0 +1,15 @@ +-- Copyright 2023 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 "User" ALTER COLUMN gaia_id DROP NOT NULL; diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index 394090c83..88bd56ca3 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -1085,7 +1085,7 @@ CREATE TABLE public."TmchCrl" ( CREATE TABLE public."User" ( id bigint NOT NULL, email_address text NOT NULL, - gaia_id text NOT NULL, + gaia_id text, registry_lock_password_hash text, registry_lock_password_salt text, global_role text NOT NULL,