accounts/console/migrations/m161222_222520_remove_oauth_access_tokens.php

32 lines
946 B
PHP
Raw Normal View History

<?php
use console\db\Migration;
class m161222_222520_remove_oauth_access_tokens extends Migration {
public function safeUp() {
$this->dropForeignKey('FK_oauth_access_toke_to_oauth_session', '{{%oauth_access_tokens}}');
$this->dropTable('{{%oauth_access_tokens}}');
}
public function safeDown() {
$this->createTable('{{%oauth_access_tokens}}', [
'access_token' => $this->string(64),
2018-04-18 02:17:25 +05:30
'session_id' => $this->getDb()->getTableSchema('{{%oauth_sessions}}')->getColumn('id')->dbType,
'expire_time' => $this->integer()->notNull(),
$this->primary('access_token'),
], $this->tableOptions);
$this->addForeignKey(
'FK_oauth_access_toke_to_oauth_session',
'{{%oauth_access_tokens}}',
'session_id',
'{{%oauth_sessions}}',
'id',
'CASCADE',
'SET NULL'
);
}
}