Passed
Push — master ( f03f32...2d9324 )
by Gabriel
10:58
created

CreateSessionsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 19
c 1
b 0
f 1
dl 0
loc 37
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A change() 0 24 2
1
<?php
2
3
declare(strict_types=1);
4
5
use Phinx\Migration\AbstractMigration;
6
7
/**
8
 * Class OrgReportsFileStatus
9
 */
10
final class CreateSessionsTable extends AbstractMigration
11
{
12
    /**
13
     * Change Method.
14
     *
15
     * Write your reversible migrations using this method.
16
     *
17
     * More information on writing migrations is available here:
18
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
19
     *
20
     * Remember to call "create()" or "update()" and NOT "save()" when working
21
     * with the Table class.
22
     */
23
    public function change(): void
24
    {
25
        $table_name = \ByTIC\Payments\Utility\PaymentsModels::sessions()->getTable();
26
        $exists = $this->hasTable($table_name);
27
        if ($exists) {
28
            return;
29
        }
30
        $table = $this->table($table_name);
31
        $table->addColumn('id_purchase', 'biginteger');
32
        $table->addColumn('gateway', 'string');
33
        $table->addColumn('type', 'string');
34
        $table->addColumn('new_status', 'string');
35
        $table->addColumn('post', 'text');
36
        $table->addColumn('get', 'text');
37
        $table->addColumn('debug', 'text');
38
        $table->addColumn('created', 'timestamp', [
39
            'default' => 'CURRENT_TIMESTAMP',
40
        ]);
41
42
        $table->addIndex(['id_purchase']);
43
        $table->addIndex(['gateway']);
44
        $table->addIndex(['type']);
45
46
        $table->save();
47
    }
48
}
49