8 use Phinx\Migration\AbstractMigration;
10 public function up() {
11 $tableName =
"cuinfo";
12 $tableColumnExpires =
"web_contract_expires";
13 $tableColumnTerm =
"web_renewal_term";
15 if ($this->hasTable($tableName)) {
17 $table = $this->table($tableName);
18 if (!$table->hasColumn($tableColumnExpires)) {
19 $this->query(
"ALTER TABLE $tableName ADD COLUMN $tableColumnExpires date;");
22 if (!$table->hasColumn($tableColumnTerm)) {
23 $this->query(
"ALTER TABLE $tableName ADD COLUMN $tableColumnTerm integer;");
26 print
"Skip $tableName, table not found.\n";
29 public function down() {
30 $tableName =
"cuinfo";
31 $tableColumnExpires =
"web_contract_expires";
32 $tableColumnTerm =
"web_renewal_term";
34 if ($this->hasTable($tableName)) {
36 $table = $this->table($tableName);
37 if ($table->hasColumn($tableColumnExpires)) {
38 $this->query(
"ALTER TABLE $tableName DROP COLUMN $tableColumnExpires;");
41 if ($table->hasColumn($tableColumnTerm)) {
42 $this->query(
"ALTER TABLE $tableName DROP COLUMN $tableColumnTerm;");
45 print
"Skip $tableName, table not found.\n";