Odyssey
2017112000_adminsettings.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 AdminSettings 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  // add to cuadminprogs table
18  $tableName = "cuadminprogs";
19  $row = $this->fetchRow( "SELECT * FROM cuadminprogs WHERE program = 'aAdminSettings'" );
20  if ( !$row ) {
21  print "Adding 'aAdminSettings'\n";
22 
23  $singleRow = ["program" => "aAdminSettings",
24  "displaytext" => "Admin Settings",
25  "description" => "Allows you to set the default banking profile for new user who auto enroll and maintain the ACH batch settings.",
26  "sort_order" => 63,
27  "def_set" => "0" ];
28  $table = $this->table( $tableName );
29  $table->insert($singleRow)->saveData();
30  } else {
31  print "'aAdminSettings' already exists in table\n";
32  }
33  }
34 
35  /* To execute this you need to run the following command:
36  * php vendor/bin/phinx rollback (using correct path to phinx)
37  * Or, to roll back to a specific time:
38  * php vendor/bin/phinx rollback -t 20151123211207
39  */
40  public function down()
41  {
42  print "Not implementing the 'down'";
43  }
44 }