Completed
Push — master ( 92ff78...57630a )
by Steve
20:35 queued 09:38
created

CreateObjectsEntityTable::change()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 33
Code Lines 20

Duplication

Lines 33
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 20
nc 2
nop 0
dl 33
loc 33
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
use Phinx\Db\Adapter\MysqlAdapter;
5
6 View Code Duplication
class CreateObjectsEntityTable extends AbstractMigration {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
7
	/**
8
	 * Change Method.
9
	 *
10
	 * Write your reversible migrations using this method.
11
	 *
12
	 * More information on writing migrations is available here:
13
	 * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
14
	 *
15
	 * The following commands can be used in this method and Phinx will
16
	 * automatically reverse them when rolling back:
17
	 *
18
	 *    createTable
19
	 *    renameTable
20
	 *    addColumn
21
	 *    renameColumn
22
	 *    addIndex
23
	 *    addForeignKey
24
	 *
25
	 * Remember to call "create()" or "update()" and NOT "save()" when working
26
	 * with the Table class.
27
	 */
28
	public function change() {
29
30
		if ($this->hasTable("objects_entity")) {
31
			return;
32
		}
33
34
		$table = $this->table("objects_entity", [
35
			'id' => false,
36
			'primary_key' => ["guid"],
37
			'engine' => "InnoDB",
38
			'encoding' => "utf8mb4",
39
			'collation' => "utf8mb4_general_ci",
40
		]);
41
42
		$table->addColumn('guid', 'integer', [
43
			'null' => false,
44
			'limit' => MysqlAdapter::INT_BIG,
45
			'precision' => 20,
46
		]);
47
48
		$table->addColumn('title', 'text', [
49
			'null' => false,
50
			'limit' => 65535,
51
		]);
52
53
		$table->addColumn('description', 'text', [
54
			'null' => false,
55
			'limit' => MysqlAdapter::TEXT_LONG,
56
		]);
57
58
		$table->save();
59
60
	}
61
}
62