0
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden synced 2024-12-25 06:53:52 +01:00
bitwarden_rs/migrations/2018-07-11-181453_create_u2f_twofactor/up.sql

15 lines
No EOL
521 B
SQL

CREATE TABLE twofactor (
uuid TEXT NOT NULL PRIMARY KEY,
user_uuid TEXT NOT NULL REFERENCES users (uuid),
type INTEGER NOT NULL,
enabled BOOLEAN NOT NULL,
data TEXT NOT NULL,
UNIQUE (user_uuid, type)
);
INSERT INTO twofactor (uuid, user_uuid, type, enabled, data)
SELECT lower(hex(randomblob(16))) , uuid, 0, 1, u.totp_secret FROM users u where u.totp_secret IS NOT NULL;
UPDATE users SET totp_secret = NULL; -- Instead of recreating the table, just leave the columns empty