up.sql 501 B

123456789101112131415
  1. CREATE TABLE twofactor (
  2. uuid CHAR(36) NOT NULL PRIMARY KEY,
  3. user_uuid CHAR(36) NOT NULL REFERENCES users (uuid),
  4. type INTEGER NOT NULL,
  5. enabled BOOLEAN NOT NULL,
  6. data TEXT NOT NULL,
  7. UNIQUE (user_uuid, type)
  8. );
  9. INSERT INTO twofactor (uuid, user_uuid, type, enabled, data)
  10. SELECT UUID(), uuid, 0, 1, u.totp_secret FROM users u where u.totp_secret IS NOT NULL;
  11. UPDATE users SET totp_secret = NULL; -- Instead of recreating the table, just leave the columns empty