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
|
|
|
|