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

CreateHmacCacheTable::change()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 22

Duplication

Lines 35
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 22
nc 2
nop 0
dl 35
loc 35
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 CreateHmacCacheTable 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("hmac_cache")) {
31
			return;
32
		}
33
34
		$table = $this->table("hmac_cache", [
35
			'id' => false,
36
			'primary_key' => ["hmac"],
37
			'engine' => "MEMORY",
38
			'encoding' => "utf8mb4",
39
			'collation' => "utf8mb4_general_ci",
40
		]);
41
42
		$table->addColumn('hmac', 'string', [
43
			'null' => false,
44
			'limit' => 252,
45
			'encoding' => "utf8",
46
			'collation' => "utf8_general_ci",
47
		]);
48
49
		$table->addColumn('ts', 'integer', [
50
			'null' => false,
51
			'limit' => MysqlAdapter::INT_REGULAR,
52
			'precision' => 10,
53
		]);
54
55
		$table->addIndex(['ts'], [
56
			'name' => "ts",
57
			'unique' => false,
58
		]);
59
60
		$table->save();
61
62
	}
63
}
64