mirror of
https://github.com/elyby/accounts.git
synced 2024-12-17 10:49:50 +05:30
bdc96d82c1
Добавлен механизм сохранения сессий и refresh_token
25 lines
875 B
PHP
25 lines
875 B
PHP
<?php
|
|
|
|
use console\db\Migration;
|
|
|
|
class m160517_151805_account_sessions extends Migration {
|
|
|
|
public function safeUp() {
|
|
$this->createTable('{{%accounts_sessions}}', [
|
|
'id' => $this->primaryKey(),
|
|
'account_id' => $this->db->getTableSchema('{{%accounts}}')->getColumn('id')->dbType . ' NOT NULL',
|
|
'refresh_token' => $this->string()->notNull()->unique(),
|
|
'last_used_ip' => $this->integer()->unsigned()->notNull(),
|
|
'created_at' => $this->integer()->notNull(),
|
|
'last_refreshed_at' => $this->integer()->notNull(),
|
|
], $this->tableOptions);
|
|
|
|
$this->addForeignKey('FK_account_session_to_account', '{{%accounts_sessions}}', 'account_id', '{{%accounts}}', 'id', 'CASCADE', 'CASCADE');
|
|
}
|
|
|
|
public function safeDown() {
|
|
$this->dropTable('{{%accounts_sessions}}');
|
|
}
|
|
|
|
}
|