Odyssey
2018041700_addPinCustomContent.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 AddPinCustomContent 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  // Need to update the sequence. This will not be needed on DEV. Initial data will be updated. However, if ever the custom content is added on production, it will need to be corrected.
19  $this->query("select setval('cucmsdocs_docsid_seq', 1000, true)");
20  // Set the sequence to a big number. It will never be used in production but when adding custom content just change the number to the next in the list.
21 
22  $this->query("insert into cucmsdocs values ('66', 'ActivateMemberPin', 'Used to gather information from the member to activate. Note: Certain form fields are required as named.',
23  '3', '', '', 'Y', 'N', 'ACTIVATE ACCOUNT PIN', 'Member Forms', '15', '', '')");
24  print "Inserted 'ActivateMemberPin' into cucmsdocs.";
25  } else {
26  print "docs table doesn't exist.\n";
27  }
28  } // End "up" function.
29 
30  public function down() {
31 
32  // check if we already made the change
33  $tableName = "cucmsdocs";
34 
35  if ($this->hasTable($tableName)) { // This table should exist but make sure.
36 
37  $this->query("delete from cucmsdocs where docsid = 66");
38  print "Delete 'ActivateMemberPin' from cucmsdocs.";
39  } else {
40  print "docs table doesn't exist.\n";
41  }
42  } // End "down" function
43 }