AddOauth2RefreshTokensTable20230802152020::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 21
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 31
rs 9.584
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Platine\Framework\Migration;
6
7
use Platine\Database\Schema\CreateTable;
0 ignored issues
show
Bug introduced by
The type Platine\Database\Schema\CreateTable was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Platine\Framework\Migration\AbstractMigration;
0 ignored issues
show
Bug introduced by
The type Platine\Framework\Migration\AbstractMigration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class AddOauth2RefreshTokensTable20230802152020 extends AbstractMigration
11
{
12
    public function up(): void
13
    {
14
      //Action when migrate up
15
        $this->create('oauth_refresh_tokens', function (CreateTable $table) {
16
            $table->string('refresh_token', 100)
17
                  ->notNull()
18
                  ->description('The refresh token')
19
                 ->primary();
20
21
            $table->string('scope', 2000)
22
                   ->description('The refresh token scopes separated with space if many');
23
24
            $table->datetime('expires')
25
                   ->notNull()
26
                   ->description('The refresh token expire time');
27
28
            $table->integer('user_id')
29
                ->description('The owner of refresh token');
30
31
            $table->string('client_id')
32
                ->description('The refresh token client')
33
                ->notNull();
34
35
            $table->timestamps();
36
37
            $table->foreign('client_id')
38
                ->references('oauth_clients', 'id')
39
                ->onDelete('NO ACTION')
40
                ->onUpdate('CASCADE');
41
42
            $table->engine('INNODB');
43
        });
44
    }
45
46
    public function down(): void
47
    {
48
      //Action when migrate down
49
        $this->drop('oauth_refresh_tokens');
50
    }
51
}
52