|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://github.com/zhuravljov/yii2-queue-monitor |
|
4
|
|
|
* @copyright Copyright (c) 2017 Roman Zhuravlev |
|
5
|
|
|
* @license http://opensource.org/licenses/BSD-3-Clause |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace zhuravljov\yii\queue\monitor\migrations; |
|
9
|
|
|
|
|
10
|
|
|
use zhuravljov\yii\queue\monitor\base\Migration; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Storage Schema |
|
14
|
|
|
* |
|
15
|
|
|
* @author Roman Zhuravlev <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class M180807000000SchemaRefactor extends Migration |
|
18
|
|
|
{ |
|
19
|
|
|
public function safeUp() |
|
20
|
|
|
{ |
|
21
|
|
|
/* First remove auto increment column */ |
|
22
|
|
|
$this->alterColumn($this->env->pushTableName,'id' ,$this->bigInteger()); |
|
23
|
|
|
/* remove primary key index */ |
|
24
|
|
|
$this->dropPrimaryKey($this->db->schema->getTableSchema($this->env->pushTableName)->primaryKey[0],$this->env->pushTableName); |
|
25
|
|
|
/* add new primary */ |
|
26
|
|
|
$this->alterColumn($this->env->pushTableName,'id' ,$this->bigPrimaryKey()); |
|
27
|
|
|
$this->alterColumn($this->env->pushTableName,'parent_id' ,$this->bigInteger()); |
|
28
|
|
|
$this->alterColumn($this->env->pushTableName,'pushed_at' ,$this->integer()->unsigned()->notNull()); |
|
29
|
|
|
$this->alterColumn($this->env->pushTableName,'stopped_at' , $this->integer()->unsigned()); |
|
30
|
|
|
$this->alterColumn($this->env->pushTableName,'first_exec_id' , $this->bigInteger()); |
|
31
|
|
|
$this->alterColumn($this->env->pushTableName,'last_exec_id' , $this->bigInteger()); |
|
32
|
|
|
|
|
33
|
|
|
$this->renameColumn($this->env->pushTableName,'push_ttr','ttr'); |
|
34
|
|
|
$this->alterColumn($this->env->pushTableName,'ttr' , $this->integer()->unsigned()); |
|
35
|
|
|
$this->renameColumn($this->env->pushTableName,'push_delay','delay'); |
|
36
|
|
|
$this->alterColumn($this->env->pushTableName,'delay' , $this->integer()->unsigned()); |
|
37
|
|
|
$this->renameColumn($this->env->pushTableName,'push_trace_data','trace'); |
|
38
|
|
|
$this->alterColumn($this->env->pushTableName,'trace' , $this->text()); |
|
39
|
|
|
$this->renameColumn($this->env->pushTableName,'push_env_data','context'); |
|
40
|
|
|
$this->alterColumn($this->env->pushTableName,'context' , $this->text()); |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
$this->alterColumn($this->env->execTableName,'id' ,$this->bigInteger()); |
|
44
|
|
|
$this->dropPrimaryKey($this->db->schema->getTableSchema($this->env->execTableName)->primaryKey[0],$this->env->execTableName); |
|
45
|
|
|
$this->alterColumn($this->env->execTableName,'id' ,$this->bigPrimaryKey()); |
|
46
|
|
|
$this->alterColumn($this->env->execTableName,'push_id' ,$this->bigInteger()->notNull()); |
|
47
|
|
|
$this->alterColumn($this->env->execTableName,'worker_id' ,$this->bigInteger()); |
|
48
|
|
|
$this->alterColumn($this->env->execTableName,'attempt' ,$this->integer()->unsigned()->notNull()); |
|
49
|
|
|
|
|
50
|
|
|
$this->renameColumn($this->env->execTableName,'reserved_at' ,'started_at'); |
|
51
|
|
|
$this->renameColumn($this->env->execTableName,'done_at' ,'finished_at'); |
|
52
|
|
|
|
|
53
|
|
|
$this->alterColumn($this->env->execTableName,'started_at' ,$this->integer()->unsigned()->notNull()); |
|
54
|
|
|
$this->alterColumn($this->env->execTableName,'finished_at' ,$this->integer()->unsigned()); |
|
55
|
|
|
$this->alterColumn($this->env->execTableName,'memory_usage' ,$this->bigInteger()->unsigned()); |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
$this->alterColumn($this->env->workerTableName,'id' ,$this->bigInteger()); |
|
59
|
|
|
$this->dropPrimaryKey($this->db->schema->getTableSchema($this->env->workerTableName)->primaryKey[0],$this->env->workerTableName); |
|
60
|
|
|
$this->alterColumn($this->env->workerTableName,'id' ,$this->bigPrimaryKey()); |
|
61
|
|
|
$this->addColumn($this->env->workerTableName,'host' ,$this->string(64)->after('sender_name')); |
|
62
|
|
|
$this->alterColumn($this->env->workerTableName,'pid' ,$this->integer()->unsigned()); |
|
63
|
|
|
$this->alterColumn($this->env->workerTableName,'started_at' ,$this->integer()->unsigned()->notNull()); |
|
64
|
|
|
$this->alterColumn($this->env->workerTableName,'pinged_at' ,$this->integer()->unsigned()->notNull()); |
|
65
|
|
|
$this->alterColumn($this->env->workerTableName,'stopped_at' ,$this->integer()->unsigned()); |
|
66
|
|
|
$this->alterColumn($this->env->workerTableName,'finished_at' ,$this->integer()->unsigned()); |
|
67
|
|
|
$this->alterColumn($this->env->workerTableName,'last_exec_id' ,$this->bigInteger()); |
|
68
|
|
|
|
|
69
|
|
|
$this->dropIndex('pid',$this->env->workerTableName); |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function safeDown() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->alterColumn($this->env->pushTableName,'id' ,$this->integer()); |
|
79
|
|
|
$this->dropPrimaryKey($this->db->schema->getTableSchema($this->env->pushTableName)->primaryKey[0],$this->env->pushTableName); |
|
80
|
|
|
$this->alterColumn($this->env->pushTableName,'id' ,$this->primaryKey()); |
|
81
|
|
|
$this->alterColumn($this->env->pushTableName,'parent_id' ,$this->integer()); |
|
82
|
|
|
$this->alterColumn($this->env->pushTableName,'pushed_at' ,$this->integer()->notNull()); |
|
83
|
|
|
$this->alterColumn($this->env->pushTableName,'stopped_at' , $this->integer()); |
|
84
|
|
|
$this->alterColumn($this->env->pushTableName,'first_exec_id' , $this->integer()); |
|
85
|
|
|
$this->alterColumn($this->env->pushTableName,'last_exec_id' , $this->integer()); |
|
86
|
|
|
|
|
87
|
|
|
$this->renameColumn($this->env->pushTableName,'ttr','push_ttr'); |
|
88
|
|
|
$this->alterColumn($this->env->pushTableName,'push_ttr' , $this->integer()); |
|
89
|
|
|
$this->renameColumn($this->env->pushTableName,'delay','push_delay'); |
|
90
|
|
|
$this->alterColumn($this->env->pushTableName,'push_delay' , $this->integer()); |
|
91
|
|
|
$this->renameColumn($this->env->pushTableName,'trace','push_trace_data'); |
|
92
|
|
|
$this->alterColumn($this->env->pushTableName,'push_trace_data' , $this->binary()); |
|
93
|
|
|
$this->renameColumn($this->env->pushTableName,'context','push_env_data'); |
|
94
|
|
|
$this->alterColumn($this->env->pushTableName,'push_env_data' , $this->binary()); |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
$this->alterColumn($this->env->execTableName,'id' ,$this->integer()); |
|
98
|
|
|
$this->dropPrimaryKey($this->db->schema->getTableSchema($this->env->execTableName)->primaryKey[0],$this->env->execTableName); |
|
99
|
|
|
$this->alterColumn($this->env->execTableName,'id' ,$this->primaryKey()); |
|
100
|
|
|
$this->alterColumn($this->env->execTableName,'push_id' ,$this->integer()->notNull()); |
|
101
|
|
|
$this->alterColumn($this->env->execTableName,'worker_id' ,$this->integer()); |
|
102
|
|
|
$this->alterColumn($this->env->execTableName,'attempt' ,$this->integer()->notNull()); |
|
103
|
|
|
|
|
104
|
|
|
$this->alterColumn($this->env->execTableName,'started_at' ,$this->integer()->notNull()); |
|
105
|
|
|
$this->alterColumn($this->env->execTableName,'finished_at' ,$this->integer()); |
|
106
|
|
|
|
|
107
|
|
|
$this->renameColumn($this->env->execTableName,'started_at' ,'reserved_at'); |
|
108
|
|
|
$this->renameColumn($this->env->execTableName,'finished_at' ,'done_at'); |
|
109
|
|
|
|
|
110
|
|
|
$this->alterColumn($this->env->execTableName,'memory_usage' ,$this->bigInteger()); |
|
111
|
|
|
|
|
112
|
|
|
$this->alterColumn($this->env->workerTableName,'id' ,$this->integer()); |
|
113
|
|
|
$this->dropPrimaryKey($this->db->schema->getTableSchema($this->env->workerTableName)->primaryKey[0],$this->env->workerTableName); |
|
114
|
|
|
$this->alterColumn($this->env->workerTableName,'id' ,$this->primaryKey()); |
|
115
|
|
|
$this->dropColumn($this->env->workerTableName,'host'); |
|
116
|
|
|
$this->alterColumn($this->env->workerTableName,'pid' ,$this->integer()); |
|
117
|
|
|
$this->alterColumn($this->env->workerTableName,'started_at' ,$this->integer()->notNull()); |
|
118
|
|
|
$this->alterColumn($this->env->workerTableName,'pinged_at' ,$this->integer()->notNull()); |
|
119
|
|
|
$this->alterColumn($this->env->workerTableName,'stopped_at' ,$this->integer()); |
|
120
|
|
|
$this->alterColumn($this->env->workerTableName,'finished_at' ,$this->integer()); |
|
121
|
|
|
$this->alterColumn($this->env->workerTableName,'last_exec_id' ,$this->integer()); |
|
122
|
|
|
|
|
123
|
|
|
$this->createIndex('pid',$this->env->workerTableName,['pid']); |
|
124
|
|
|
} |
|
125
|
|
|
} |