These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Phinx\Migration\AbstractMigration; |
||
4 | use Phinx\Db\Adapter\MysqlAdapter; |
||
5 | |||
6 | View Code Duplication | class CreateGroupsEntityTable extends AbstractMigration { |
|
0 ignored issues
–
show
|
|||
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("groups_entity")) { |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | $table = $this->table("groups_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 | 'signed' => false, |
||
47 | ]); |
||
48 | |||
49 | $table->addColumn('name', 'text', [ |
||
50 | 'null' => false, |
||
51 | 'limit' => 65535, |
||
52 | ]); |
||
53 | |||
54 | $table->addColumn('description', 'text', [ |
||
55 | 'null' => false, |
||
56 | 'limit' => MysqlAdapter::TEXT_LONG, |
||
57 | ]); |
||
58 | |||
59 | $table->addIndex(['name'], [ |
||
60 | 'name' => "name", |
||
61 | 'unique' => false, |
||
62 | 'limit' => 50, |
||
63 | ]); |
||
64 | |||
65 | $table->addIndex(['description'], [ |
||
66 | 'name' => "description", |
||
67 | 'unique' => false, |
||
68 | 'limit' => 50 |
||
69 | ]); |
||
70 | |||
71 | $table->save(); |
||
72 | |||
73 | } |
||
74 | } |
||
75 |
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.