Completed
Pull Request — devel (#18)
by Maxime
37:07
created

m180618_134300_oauthAuthorizationCodes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 52
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 34 1
A safeDown() 0 7 1
1
<?php
2
/**
3
 * m180618_134300_oauthAuthorizationCodes.php
4
 * PHP version 5.6+
5
 *
6
 * Create applicants
7
 *
8
 * @author Maxime Deschamps <[email protected]>
9
 * @copyright 2010-2018 Ibitux
10
 * @license http://www.ibitux.com/license license
11
 * @version XXX
12
 * @link http://www.ibitux.com
13
 * @package src\migrations
14
 */
15
16
use yii\db\Migration;
17
18
/**
19
 * Class m180618_134300_oauthAuthorizationCodes
20
 *
21
 * @author Maxime Deschamps <[email protected]>
22
 * @copyright 2010-2018 Ibitux
23
 * @license http://www.ibitux.com/license license
24
 * @version XXX
25
 * @link http://www.ibitux.com
26
 * @package src\migrations
27
 * @since XXX
28
 */
29
class m180618_134300_oauthAuthorizationCodes extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
30
{
31
    /**
32
     * @inheritdoc
33
     */
34
    public function safeUp()
35
    {
36
        $this->createTable('{{%oauthAuthorizationCodes}}', [
37
            'id' => $this->string(255),
38
            'clientId' => $this->string(255),
39
            'userId' => $this->string(255),
40
            'redirectUri' => $this->string(255),
41
            'expiry' => $this->dateTime(),
42
            'tokenId' => $this->string(255),
43
            'dateCreated' => $this->datetime(),
44
            'dateUpdated' => $this->datetime(),
45
            'dateDeleted' => $this->dateTime(),
46
            'PRIMARY KEY(id)',
47
        ], 'ENGINE=InnoDB DEFAULT CHARSET=utf8');
48
        $this->addForeignKey(
49
            'authorizationCodes_clients_id_fk',
50
            '{{%oauthAuthorizationCodes}}',
51
            'clientId',
52
            '{{%oauthClients}}',
53
            'id',
54
            'SET NULL',
55
            'CASCADE'
56
        );
57
        $this->addForeignKey(
58
            'authorizationCodes_accessTokens_id_fk',
59
            '{{%oauthAuthorizationCodes}}',
60
            'tokenId',
61
            '{{%oauthAccessTokens}}',
62
            'id',
63
            'SET NULL',
64
            'CASCADE'
65
        );
66
        return true;
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function safeDown()
73
    {
74
        $this->dropForeignKey('authorizationCodes_accessTokens_id_fk', '{{%oauthAuthorizationCodes}}');
75
        $this->dropForeignKey('authorizationCodes_clients_id_fk', '{{%oauthAuthorizationCodes}}');
76
        $this->dropTable('{{%oauthAuthorizationCodes}}');
77
        return true;
78
    }
79
80
}
81