2018-07-12 22:46:50 +03:00
|
|
|
CREATE TABLE twofactor (
|
2019-05-27 18:20:20 +03:00
|
|
|
uuid CHAR(36) NOT NULL PRIMARY KEY,
|
|
|
|
user_uuid CHAR(36) NOT NULL REFERENCES users (uuid),
|
2019-05-27 00:02:41 +03:00
|
|
|
type INTEGER NOT NULL,
|
2018-07-12 22:46:50 +03:00
|
|
|
enabled BOOLEAN NOT NULL,
|
|
|
|
data TEXT NOT NULL,
|
|
|
|
|
2019-05-27 00:02:41 +03:00
|
|
|
UNIQUE (user_uuid, type)
|
2018-07-12 22:46:50 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2019-05-27 00:02:41 +03:00
|
|
|
INSERT INTO twofactor (uuid, user_uuid, type, enabled, data)
|
2019-05-20 22:12:41 +03:00
|
|
|
SELECT UUID(), uuid, 0, 1, u.totp_secret FROM users u where u.totp_secret IS NOT NULL;
|
2018-07-12 22:46:50 +03:00
|
|
|
|
2019-05-20 22:12:41 +03:00
|
|
|
UPDATE users SET totp_secret = NULL; -- Instead of recreating the table, just leave the columns empty
|