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

CreateGeoCacheTable::change()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 20
nc 2
nop 0
dl 0
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
class CreateGeoCacheTable extends AbstractMigration {
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("geocode_cache")) {
31
			return;
32
		}
33
34
		$table = $this->table("geocode_cache", [
35
			'engine' => "MEMORY",
36
			'encoding' => "utf8mb4",
37
			'collation' => "utf8mb4_general_ci",
38
		]);
39
40
		$table->addColumn('location', 'string', [
41
			'null' => true,
42
			'limit' => 128,
43
		]);
44
45
		$table->addColumn('lat', 'string', [
46
			'null' => true,
47
			'limit' => 20,
48
		]);
49
50
		$table->addColumn('long', 'string', [
51
			'null' => true,
52
			'limit' => 20,
53
		]);
54
55
		$table->addIndex(['location'], [
56
			'name' => "location",
57
			'unique' => true
58
		]);
59
60
		$table->save();
61
62
	}
63
}
64