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

OAuth2Apps::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 19
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 21
rs 9.3142
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class OAuth2Apps extends AbstractMigration
6
{
7
    /**
8
     * Create OAuth2 application table
9
     */
10
    public function change()
11
    {
12
        $oauthApps = $this->table('oauth2_apps');
13
        $oauthApps->addColumn('created', 'datetime', ['comment' => 'Created'])
14
              ->addColumn('users_uuid', 'string', ['comment' => 'User UUID', 'limit' => 36])
15
              ->addColumn('client_id', 'string', ['comment' => 'Client Id', 'limit' => 36])
16
              ->addColumn('client_secret', 'string', ['comment' => 'Client Secret', 'limit' => 36])
17
              ->addColumn('name', 'string', ['comment' => 'Application Name', 'limit' => 255])
18
              ->addColumn('logo_url', 'text', ['comment' => 'Logo Image URL', 'limit' => 1024, 'null' => true])
19
              ->addColumn('description', 'text', ['comment' => 'Description', 'null' => true])
20
              ->addColumn('scope', 'text', ['comment' => 'Allowed Scopes', 'null' => true])
21
              ->addColumn('callback_uri', 'text', ['comment' => 'Callback URI', 'null' => true])
22
              ->addColumn('redirect_uris', 'text', ['comment' => 'Redirect URIs', 'null' => true])
23
              ->addColumn('status', 'string', ['comment' => 'Status', 'limit' => 16, 'default' => 'NEW'])
24
              ->addIndex(['name'], ['unique' => true])
25
              ->addIndex(['client_id'], ['unique' => true])
26
              ->addIndex(['client_secret'], ['unique' => true])
27
              ->addIndex(['client_id', 'client_secret'], ['unique' => true])
28
              ->addForeignKey('users_uuid', 'users', 'uuid', ['delete'=> 'CASCADE', 'update'=> 'CASCADE'])
29
              ->save();
30
    }
31
}
32