Fix db migration that adds support for OIDC in the data warehouse (#1471)

Four new columns were added to the `wh_user_dimension` table to support
OIDC. The data type for the columns was originally `wh_dim_text` which
is a domain type with a `not null` restriction. Adding the new columns
caused the migration to fail if the `wh_user_dimension` table had any
rows in it because the existing rows would violate the `not null`
restriction.

Closes #1469
This commit is contained in:
Michael Gaffney authored and GitHub committed 2021-08-18 22:18:51 -04:00
1 parent b0dbd0182e
commit 5f88243ddc
3 files changed
+231 -8

No files matched your search

+33 -4
View File
@@ -6138,10 +6138,39 @@ alter table auth_oidc_account
`),
14001: []byte(`
alter table wh_user_dimension
add column auth_method_external_id wh_dim_text,
add column auth_account_external_id wh_dim_text,
add column auth_account_full_name wh_dim_text,
add column auth_account_email wh_dim_text
add column auth_method_external_id text,
add column auth_account_external_id text,
add column auth_account_full_name text,
add column auth_account_email text
;
update wh_user_dimension
set auth_method_type =
case when auth_method_id like 'ampw_%' then 'password auth method'
when auth_method_id like 'amoidc_%' then 'oidc auth method'
else 'Unknown' end,
auth_account_type =
case when auth_account_id like 'acctpw_%' then 'password auth account'
when auth_account_id like 'acctoidc_%' then 'oidc auth account'
else 'Unknown' end,
auth_method_external_id =
case when auth_method_id like 'ampw_%' then 'Not Applicable'
else 'Unknown' end,
auth_account_external_id =
case when auth_method_id like 'ampw_%' then 'Not Applicable'
else 'Unknown' end,
auth_account_full_name =
case when auth_method_id like 'ampw_%' then 'Not Applicable'
else 'Unknown' end,
auth_account_email =
case when auth_method_id like 'ampw_%' then 'Not Applicable'
else 'Unknown' end;
alter table wh_user_dimension
alter column auth_method_external_id type wh_dim_text,
alter column auth_account_external_id type wh_dim_text,
alter column auth_account_full_name type wh_dim_text,
alter column auth_account_email type wh_dim_text
;
drop view whx_user_dimension_source;