-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
/** | ||
* Class m190521_145029_admin_user_notification | ||
*/ | ||
class m200128_141129_v3_update extends Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeUp() | ||
{ | ||
// user login agent | ||
$this->addColumn('{{%admin_user_login}}', 'user_agent', $this->string()); | ||
|
||
// user device | ||
$this->createTable('{{%admin_user_device}}', [ | ||
'id' => $this->primaryKey(), | ||
'user_id' => $this->integer()->notNull(), | ||
'auth_key' => $this->string(190)->unique()->notNull(), | ||
'user_agent' => $this->string()->notNull(), | ||
'user_agent_checksum' => $this->string()->notNull(), | ||
'created_at' => $this->integer(), | ||
'updated_at' => $this->integer(), | ||
]); | ||
|
||
$this->createIndex('user_id', '{{%admin_user_device}}', ['user_id']); | ||
$this->createIndex('auth_key', '{{%admin_user_device}}', ['auth_key']); | ||
|
||
// user 2fa | ||
$this->addColumn('{{%admin_user}}', 'login_2fa_enabled', $this->boolean()->defaultValue(false)); | ||
$this->addColumn('{{%admin_user}}', 'login_2fa_secret', $this->string()); | ||
$this->addColumn('{{%admin_user}}', 'login_2fa_backup_key', $this->string()); | ||
|
||
// queue | ||
$this->createTable('{{%admin_queue_log_error}}', [ | ||
'id' => $this->primaryKey(), | ||
'queue_log_id' => $this->integer()->notNull(), | ||
'message' => $this->text(), | ||
'code' => $this->string(), | ||
'trace' => $this->text(), | ||
'file' => $this->text(), | ||
'line' => $this->string(), | ||
'created_at' => $this->integer(), | ||
'updated_at' => $this->integer(), | ||
]); | ||
|
||
$this->createIndex('queue_log_id', '{{%admin_queue_log_error}}', 'queue_log_id'); | ||
|
||
// user login lockout | ||
$this->createTable('{{%admin_user_login_lockout}}', [ | ||
'id' => $this->primaryKey(), | ||
'user_id' => $this->integer()->notNull(), | ||
'ip' => $this->string(45)->notNull(), | ||
'attempt_count' => $this->integer()->defaultValue(0), | ||
'created_at' => $this->integer(), | ||
'updated_at' => $this->integer(), | ||
]); | ||
|
||
$this->createIndex('user_id', '{{%admin_user_login_lockout}}', 'user_id'); | ||
|
||
// password restore link | ||
$this->addColumn('{{%admin_user}}', 'password_verification_token', $this->string(40)); | ||
$this->addColumn('{{%admin_user}}', 'password_verification_token_timestamp', $this->integer()); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeDown() | ||
{ | ||
// user login UA | ||
$this->dropColumn('{{%admin_user_login}}', 'user_agent'); | ||
|
||
// user device | ||
$this->dropTable('{{%admin_user_device}}'); | ||
|
||
// user 2fa | ||
$this->dropColumn('{{%admin_user}}', 'login_2fa_enabled'); | ||
$this->dropColumn('{{%admin_user}}', 'login_2fa_secret'); | ||
$this->dropColumn('{{%admin_user}}', 'login_2fa_backup_key'); | ||
|
||
// queue error log | ||
$this->dropTable('{{%admin_queue_log_error}}'); | ||
|
||
// user lockout | ||
$this->dropTable('{{%admin_user_login_lockout}}'); | ||
|
||
// password restore link | ||
$this->dropColumn('{{%admin_user}}', 'password_verification_token'); | ||
$this->dropColumn('{{%admin_user}}', 'password_verification_token_timestamp'); | ||
} | ||
} |