diff --git a/common.php b/common.php index 3ea4681c..fa499419 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is const MYAAC = true; const MYAAC_VERSION = '2.0-dev'; -const DATABASE_VERSION = 50; +const DATABASE_VERSION = 51; const TABLE_PREFIX = 'myaac_'; define('START_TIME', microtime(true)); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/system/migrations/51.php b/system/migrations/51.php index b3d9bbc7..d6a78207 100644 --- a/system/migrations/51.php +++ b/system/migrations/51.php @@ -1 +1,36 @@ hasColumn('accounts', '2fa_type')) { + $db->addColumn('accounts', '2fa_type', "tinyint NOT NULL DEFAULT 0 AFTER `web_flags`"); + } + + if (!$db->hasColumn('accounts', '2fa_secret')) { + $db->addColumn('accounts', '2fa_secret', "varchar(16) NOT NULL DEFAULT '' AFTER `2fa_type`"); + } + + // add myaac_account_email_codes table + if (!$db->hasTable(TABLE_PREFIX . 'account_email_codes')) { + $db->exec(file_get_contents(__DIR__ . '/46-account_email_codes.sql')); + } +}; + +$down = function () use ($db) { + if ($db->hasColumn('accounts', '2fa_type')) { + $db->dropColumn('accounts', '2fa_type'); + } + + if ($db->hasColumn('accounts', '2fa_secret')) { + $db->dropColumn('accounts', '2fa_secret'); + } + + if ($db->hasTable(TABLE_PREFIX . 'account_email_codes')) { + $db->dropTable(TABLE_PREFIX . 'account_email_codes'); + } +};