Test Failed
Push — master ( c9f7be...859573 )
by Gabriel
06:41
created

CreateMediaTable::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 14
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 22
rs 9.7998
1
<?php
2
declare(strict_types=1);
3
4
use Phinx\Migration\AbstractMigration;
5
6
/**
7
 * Class OrgReportsFileStatus
8
 */
9
final class CreateMediaTable extends AbstractMigration
10
{
11
    /**
12
     * Change Method.
13
     *
14
     * Write your reversible migrations using this method.
15
     *
16
     * More information on writing migrations is available here:
17
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
18
     *
19
     * Remember to call "create()" or "update()" and NOT "save()" when working
20
     * with the Table class.
21
     */
22
    public function change(): void
23
    {
24
        $table = $this->table('media-records');
25
26
        $table->addColumn('model', 'string');
27
        $table->addColumn('model_id', 'biginteger');
28
        $table->addColumn('collection_name', 'string');
29
30
        $table->addColumn('file_name', 'string');
31
        $table->addColumn('path', 'string');
32
        $table->addColumn('disk', 'string');
33
34
        $table->addIndex(['model']);
35
        $table->addIndex(['model_id']);
36
        $table->addIndex(['collection_name']);
37
38
        $table->addIndex(['model', 'model_id', 'collection_name', 'path'], ['unique' => true]);
39
40
        $table->save();
41
42
        $table->changeColumn('id', 'biginteger', ['identity' => true]);
43
        $table->save();
44
    }
45
}
46