00006-add-totp-user-fields.sql 616 B

1234567891011121314151617181920212223
  1. -- Create totp_secret field if it doesn't exist
  2. ALTER TABLE "user"
  3. ADD COLUMN IF NOT EXISTS "totp_secret" text DEFAULT NULL;
  4. -- Create totp_enabled field if it doesn't exist
  5. ALTER TABLE "user"
  6. ADD COLUMN IF NOT EXISTS "totp_enabled" boolean DEFAULT FALSE;
  7. -- Add salt field to user table
  8. ALTER TABLE "user"
  9. ADD COLUMN IF NOT EXISTS "salt" text DEFAULT NULL;
  10. -- Set all users to have totp enabled false
  11. UPDATE
  12. "user"
  13. SET
  14. "totp_enabled" = FALSE
  15. WHERE
  16. "totp_enabled" IS NULL;
  17. -- Set totp_enabled column to not null constraint
  18. ALTER TABLE "user"
  19. ALTER COLUMN "totp_enabled" SET NOT NULL;