mirror of
https://github.com/ellite/Wallos.git
synced 2025-12-23 23:18:07 -05:00
20 lines
634 B
PHP
20 lines
634 B
PHP
<?php
|
|
|
|
// this migration adds a "totp_enabled" column to the user table
|
|
// it also adds a "totp" table to the database
|
|
|
|
$columnQuery = $db->query("SELECT * FROM pragma_table_info('user') where name='totp_enabled'");
|
|
|
|
$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
|
|
|
|
if ($columnRequired) {
|
|
$db->exec('ALTER TABLE user ADD COLUMN totp_enabled BOOLEAN DEFAULT 0');
|
|
}
|
|
|
|
$db->exec('CREATE TABLE IF NOT EXISTS totp (
|
|
user_id INTEGER NOT NULL,
|
|
totp_secret TEXT NOT NULL,
|
|
backup_codes TEXT NOT NULL,
|
|
last_totp_used INTEGER DEFAULT 0,
|
|
FOREIGN KEY(user_id) REFERENCES user(id)
|
|
)'); |