Odyssey
tools
cumanage
db
migrations
2017041400_onlineActivity.php
1
<?php
2
/* Notes:
3
* 1. Anything complicated needs to be done with SQL.
4
* 2. Always have a check to know if the migration needs to occur (up or down).
5
* 3. Use up() and down(), not change(), because of the SQL
6
*/
7
use Phinx\Migration\AbstractMigration;
8
9
class
OnlineActivity
extends
AbstractMigration {
10
11
/* This is the process for moving forward. We are re-creating the table so if there is
12
* existing data will need to create a temporary table, copy the data, drop the old table,
13
* rename the temporary table.
14
*/
15
public
function
up() {
16
17
if
(!$this->hasTable(
"cu_scheduledtxn"
))
18
{
19
print
"Table doesn't exist. Nothing done. Please run 2017033000_scheduledtxn.php first."
;
20
}
21
else
22
{
23
$table= $this->table(
"cu_scheduledtxn"
);
24
25
if
(!$table->hasColumn(
'approved_status'
))
26
{
27
print
"Adding approved_status to table.\n"
;
28
$this->query(
"alter table cu_scheduledtxn add column approved_status smallint default 0"
);
29
}
30
}
31
}
32
33
/* To execute this you need to run the following command:
34
* php vendor/bin/phinx rollback (using correct path to phinx)
35
* Or, to roll back to a specific time:
36
* php vendor/bin/phinx rollback -t 20151123211207
37
*/
38
public
function
down() {
39
if
(!$this->hasTable(
"cu_scheduledtxn"
))
40
{
41
print
"Table doesn't exist. Nothing done. Please run 2017033000_scheduledtxn.php first."
;
42
}
43
else
if
(!$this->table(
"cu_scheduledtxn"
)->hasColumn(
'approved_status'
))
44
{
45
$table= $this->table(
"cu_scheduledtxn"
);
46
47
if
($table->hasColumn(
"approved_status"
))
48
{
49
print
"Removing approved_status from cu_scheduledtxn"
;
50
$table->removeColumn(
'approved_status'
)->save();
51
}
52
}
53
}
54
}
55
56
?>
OnlineActivity
Definition:
2017041400_onlineActivity.php:9
Generated by
1.8.15