Odyssey
2019061200_addMobileRDCInstruct.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 AddMobileRDCInstruct extends AbstractMigration {
11  public function up() {
12 
13  // check if we already made the change
14  $tableName = "cucmsdocs";
15 
16  if ($this->hasTable($tableName)) { // This table should exist but make sure.
17 
18  // specify the columns so automatically get next sequence number
19  $this->query("insert into cucmsdocs (docsname, docsdesc, docstype,
20  docsdisplaylink, docsdisplaytext, docsdefaultavail,
21  docsresponsetype, docstitle, docsmaintsection,
22  docsmaintsort, docstarget, docstargetname)
23  values ('mblRDCInstructions', 'Helpful instructions and/or notice for the user.',
24  '2', 'Y', 'Instructions', 'Y', 'N', '', 'Mobile', '65', '', '')");
25  print "Inserted 'mblRDCInstructions' into cucmsdocs.\n";
26  } else {
27  print "docs table doesn't exist.\n";
28  }
29  } // End "up" function.
30 
31  public function down() {
32 
33  // check if we already made the change
34  $tableName = "cucmsdocs";
35 
36  if ($this->hasTable($tableName)) { // This table should exist but make sure.
37 
38  $this->query("delete from cucmsdocs where docsname = 'mblRDCInstructions'");
39  print "Delete 'mblRDCInstructions' from cucmsdocs.\n";
40  } else {
41  print "docs table doesn't exist.\n";
42  }
43  } // End "down" function
44 }