Completed
Push — dev-master ( 50729f...83e592 )
by Vijay
04:16
created

OAuth2Tokens::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
rs 9.4285
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class OAuth2Tokens extends AbstractMigration
6
{
7
    /**
8
    * Create OAuth2 application tokens table
9
      */
10
    public function change()
11
    {
12
        $oauthTokens = $this->table('oauth2_tokens');
13
        $oauthTokens->addColumn('uuid', 'string', ['comment' => 'UUID', 'limit' => 36, 'null' => false])
14
              ->addColumn('created', 'datetime', ['comment' => 'Created'])
15
              ->addColumn('expires', 'datetime', ['comment' => 'Expires', 'null' => true])
16
              ->addColumn('users_uuid', 'string', ['comment' => 'User UUID', 'limit' => 36])
17
              ->addColumn('client_id', 'string', ['comment' => 'Client Id', 'limit' => 36])
18
              ->addColumn('token', 'string', ['comment' => 'Token Value', 'limit' => 36])
19
              ->addColumn('type', 'string', ['comment' => 'Token Type', 'limit' => 16])
20
              ->addColumn('scope', 'text', ['comment' => 'Allowed Scopes', 'null' => true])
21
              ->addIndex(['uuid'], ['unique' => true])
22
              ->addIndex(['token'], ['unique' => true])
23
              ->addIndex(['client_id', 'users_uuid', 'type'], ['unique' => true])
24
              ->addForeignKey('client_id', 'oauth2_apps', 'client_id', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
25
              ->addForeignKey('users_uuid', 'users', 'uuid', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
26
              ->save();
27
    }
28
}
29