Completed
Pull Request — master (#47)
by
unknown
02:19
created

safeDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
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_000003_create_social_account_table extends Migration
18
{
19
    public function safeUp()
20
    {
21
        $this->createTable(
22
            '{{%social_account}}',
23
            [
24
                'id' => $this->primaryKey(),
25
                'user_id' => $this->integer(),
26
                'provider' => $this->string(255)->notNull(),
27
                'client_id' => $this->string(255)->notNull(),
28
                'code' => $this->string(32),
29
                'email' => $this->string(255),
30
                'username' => $this->string(255),
31
                'data' => $this->text(),
32
                'created_at' => $this->integer(),
33
            ],
34
            MigrationHelper::resolveTableOptions($this->db->driverName)
35
        );
36
37
        $this->createIndex(
38
            'idx_social_account_provider_client_id',
39
            '{{%social_account}}',
40
            ['provider', 'client_id'],
41
            true
42
        );
43
44
        $this->createIndex('idx_social_account_code', '{{%social_account}}', 'code', true);
45
46
        $this->addForeignKey(
47
            'fk_social_account_user',
48
            '{{%social_account}}',
49
            'user_id',
50
            '{{%user}}',
51
            'id',
52
            'CASCADE',
53
            (MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT')
54
        );
55
    }
56
57
    public function safeDown()
58
    {
59
        $this->dropTable('{{%social_account}}');
60
    }
61
}
62