Completed
Push — master ( 050600...86bb02 )
by Antonio
04:26 queued 02:22
created

m000000_000004_create_token_table::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 2
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-usuario project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\User\Migration;
13
14
use Da\User\Helper\MigrationHelper;
15
use yii\db\Migration;
16
17
class m000000_000004_create_token_table extends Migration
18
{
19
    public function safeUp()
20
    {
21
        $this->createTable(
22
            '{{%token}}',
23
            [
24
                'user_id' => $this->integer(),
25
                'code' => $this->string(32)->notNull(),
26
                'type' => $this->smallInteger(6)->notNull(),
27
                'created_at' => $this->integer()->notNull(),
28
            ],
29
            MigrationHelper::resolveTableOptions($this->db->driverName)
30
        );
31
32
        $this->createIndex('idx_token_user_id_code_type', '{{%token}}', ['user_id', 'code', 'type'], true);
33
34
        $restrict = MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT';
35
36
        $this->addForeignKey('fk_token_user', '{{%token}}', 'user_id', '{{%user}}', 'id', 'CASCADE', $restrict);
37
    }
38
39
    public function safeDown()
40
    {
41
        $this->dropTable('{{%token}}');
42
    }
43
}
44