mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Do not validate constraint when creating it
To avoid locking production database for extended amounts of time.
This commit is contained in:
@@ -16,11 +16,11 @@ def upgrade():
|
|||||||
op.execute("INSERT INTO auth_type VALUES ('webauthn_auth')")
|
op.execute("INSERT INTO auth_type VALUES ('webauthn_auth')")
|
||||||
|
|
||||||
op.drop_constraint('ck_users_mobile_or_email_auth', 'users', type_=None, schema=None)
|
op.drop_constraint('ck_users_mobile_or_email_auth', 'users', type_=None, schema=None)
|
||||||
op.create_check_constraint(
|
op.execute("""
|
||||||
'ck_user_has_mobile_or_other_auth',
|
ALTER TABLE users ADD CONSTRAINT "ck_user_has_mobile_or_other_auth"
|
||||||
'users',
|
CHECK (auth_type in ('email_auth', 'webauthn_auth') or mobile_number is not null)
|
||||||
"auth_type in ('email_auth', 'webauthn_auth') or mobile_number is not null"
|
NOT VALID
|
||||||
)
|
""")
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
@@ -30,11 +30,11 @@ def downgrade():
|
|||||||
op.execute("UPDATE invited_users SET auth_type = 'sms_auth' WHERE auth_type = 'webauthn_auth'")
|
op.execute("UPDATE invited_users SET auth_type = 'sms_auth' WHERE auth_type = 'webauthn_auth'")
|
||||||
|
|
||||||
op.drop_constraint('ck_user_has_mobile_or_other_auth', 'users', type_=None, schema=None)
|
op.drop_constraint('ck_user_has_mobile_or_other_auth', 'users', type_=None, schema=None)
|
||||||
op.create_check_constraint(
|
op.execute("""
|
||||||
'ck_users_mobile_or_email_auth',
|
ALTER TABLE users ADD CONSTRAINT "ck_users_mobile_or_email_auth"
|
||||||
'users',
|
CHECK (auth_type = 'email_auth' or mobile_number is not null)
|
||||||
"auth_type = 'email_auth' or mobile_number is not null"
|
NOT VALID
|
||||||
)
|
""")
|
||||||
|
|
||||||
op.execute("DELETE FROM auth_type WHERE name = 'webauthn_auth'")
|
op.execute("DELETE FROM auth_type WHERE name = 'webauthn_auth'")
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|||||||
Reference in New Issue
Block a user