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

m000000_000002_create_profile_table   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 22 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->primaryKey(),
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
        $restrict = MigrationHelper::isMicrosoftSQLServer($this->db->driverName) ? 'NO ACTION' : 'RESTRICT';
38
39
        $this->addForeignKey('fk_profile_user', '{{%profile}}', 'user_id', '{{%user}}', 'id', 'CASCADE', $restrict);
40
    }
41
42
    public function safeDown()
43
    {
44
        $this->dropTable('{{%profile}}');
45
    }
46
}
47