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

CreateMediaPropertiesTable::change()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 12
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 19
rs 9.8666
1
<?php
2
declare(strict_types=1);
3
4
use Phinx\Migration\AbstractMigration;
5
6
/**
7
 * Class OrgReportsFileStatus
8
 */
9
final class CreateMediaPropertiesTable 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-properties');
25
26
        $table->addColumn('model', 'string');
27
        $table->addColumn('model_id', 'biginteger');
28
        $table->addColumn('collection_name', 'string');
29
30
        $table->addColumn('custom_properties', 'json');
31
32
        $table->addIndex(['model']);
33
        $table->addIndex(['model_id']);
34
        $table->addIndex(['collection_name']);
35
        $table->addIndex(['model', 'model_id', 'collection_name'], ['unique' => true]);
36
37
        $table->save();
38
39
        $table->changeColumn('id', 'biginteger', ['identity' => true]);
40
        $table->save();
41
    }
42
}
43