m000000_000002_create_profile_table   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 24 2
A safeDown() 0 4 1
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_000002_create_profile_table extends Migration
18
{
19
    public function safeUp()
20
    {
21
        $this->createTable(
22
            '{{%profile}}',
23
            [
24
                'user_id' => $this->integer()->notNull(),
25
                'name' => $this->string(255),
26
                'public_email' => $this->string(255),
27
                'gravatar_email' => $this->string(255),
28
                'gravatar_id' => $this->string(32),
29
                'location' => $this->string(255),
30
                'website' => $this->string(255),
31
                'timezone' => $this->string(40),
32
                'bio' => $this->text(),
33
            ],
34
            MigrationHelper::resolveTableOptions($this->db->driverName)
35
        );
36
37
        $this->addPrimaryKey('{{%profile_pk}}', '{{%profile}}', 'user_id');
38
39
        $restrict = MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT';
40
41
        $this->addForeignKey('fk_profile_user', '{{%profile}}', 'user_id', '{{%user}}', 'id', 'CASCADE', $restrict);
42
    }
43
44
    public function safeDown()
45
    {
46
        $this->dropTable('{{%profile}}');
47
    }
48
}
49