Odyssey
2018042500_adminSettingsNotAuto.php
1 <?php
2 /**
3  * Notes:
4  * 1. Anything complicated needs to be done with SQL.
5  * 2. Always have a check to know if the migration needs to occur (up or down).
6  * 3. Use up() and down(), not change(), because of the SQL
7  */
8 use Phinx\Migration\AbstractMigration;
9 
10 class AdminSettingsNotAuto extends AbstractMigration {
11  public function up() {
12 
13  // check if we already made the change
14  $tableName = "cuadminprogs";
15 
16  if ($this->hasTable($tableName)) { // This table should exist but make sure.
17 
18  // This is to prevent program from being auto-added to CUADMINEXCLUDE in cuset.pl.
19  $this->query("update cuadminprogs set def_set = 1 where program = 'aAdminSettings'");
20 
21  print "Updated aAdminSettings record in cuadminprogs.";
22  } else {
23  print "Admin programs table doesn't exist.\n";
24  }
25  } // End "up" function.
26 
27  public function down() {
28 
29  // check if we already made the change
30  $tableName = "cuadminprogs";
31 
32  if ($this->hasTable($tableName)) { // This table should exist but make sure.
33 
34  // This is to prevent program from being auto-added to CUADMINEXCLUDE in cuset.pl.
35  $this->query("update cuadminprogs set def_set = 0 where program = 'aAdminSettings'");
36 
37  print "Updated aAdminSettings record in cuadminprogs.";
38  } else {
39  print "Admin programs table doesn't exist.\n";
40  }
41  } // End "down" function
42 }