Files
coder/coderd/database/migrations/000258_add_otp_reset_to_user.up.sql
2024-09-25 17:46:51 +01:00

14 lines
789 B
SQL

ALTER TABLE users ADD COLUMN hashed_one_time_passcode bytea;
COMMENT ON COLUMN users.hashed_one_time_passcode IS 'A hash of the one-time-passcode given to the user.';
ALTER TABLE users ADD COLUMN one_time_passcode_expires_at timestamp with time zone;
COMMENT ON COLUMN users.one_time_passcode_expires_at IS 'The time when the one-time-passcode expires.';
ALTER TABLE users ADD CONSTRAINT one_time_passcode_set CHECK (
(hashed_one_time_passcode IS NULL AND one_time_passcode_expires_at IS NULL)
OR (hashed_one_time_passcode IS NOT NULL AND one_time_passcode_expires_at IS NOT NULL)
);
ALTER TABLE users ADD COLUMN must_reset_password bool NOT NULL DEFAULT false;
COMMENT ON COLUMN users.must_reset_password IS 'Determines if the user should be forced to change their password.';