Completed
Push — master ( 7e8f2a...c477ee )
by Anton
04:56 queued 04:54
created

Media   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 45
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/skeleton
5
 */
6
7
use Phinx\Migration\AbstractMigration;
8
9
/**
10
 * CreateMediaTable
11
 */
12
class Media extends AbstractMigration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
{
14
    /**
15
     * Change Method.
16
     *
17
     * Write your reversible migrations using this method.
18
     *
19
     * More information on writing migrations is available here:
20
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
21
     *
22
     * The following commands can be used in this method and Phinx will
23
     * automatically reverse them when rolling back:
24
     *
25
     *    createTable
26
     *    renameTable
27
     *    addColumn
28
     *    renameColumn
29
     *    addIndex
30
     *    addForeignKey
31
     *
32
     * Remember to call "create()" or "update()" and NOT "save()" when working
33
     * with the Table class.
34
     *
35
     * @throws \InvalidArgumentException
36
     * @throws \RuntimeException
37
     */
38
    public function change()
39
    {
40
        $table = $this->table('media');
41
        $table
42
            ->addColumn('userId', 'integer')
43
            ->addColumn('module', 'string', ['length' => 255, 'default' => 'users'])
44
            ->addColumn('title', 'text')
45
            ->addColumn('type', 'string', ['length' => 255])
46
            ->addColumn('file', 'string', ['length' => 255])
47
            ->addColumn('thumb', 'string', ['length' => 255])
48
            ->addColumn('size', 'integer')
49
            ->addTimestamps('created', 'updated')
50
            ->addForeignKey('userId', 'users', 'id', [
51
                'delete' => 'CASCADE',
52
                'update' => 'CASCADE'
53
            ])
54
            ->create();
55
    }
56
}
57