Odyssey
2019031200_billingpermissions.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 BillingPermissions extends AbstractMigration {
11  public function up() {
12  $tableName = "dmsmonitorusers";
13  $removalList = array("chris", "elaine", "jan", "joe", "kip", "maddie", "manny");
14  // Check for table
15  if ($this->hasTable($tableName)) {
16  // Remove from list. When assigning tasks to people, there is a bloated list.
17  $sql = "delete from $tableName where user_name in ('" . implode("', '", $removalList) . "')";
18  $this->query($sql);
19 
20  // Now replace the hcubill permission with the billing permission. Only four users in mammoth monitor do not have permissions to all scripts.
21  // At this time, this change will only affect Casey.
22  $sql = "update dmsmonitorusers set allowed_scripts = replace(allowed_scripts, 'hcubill', 'billing') where strpos(allowed_scripts, 'hcubill') > 0";
23  $this->query($sql);
24 
25  // The other permissions are more complicated but fortunately at this time, all users in those lists are allowed access to all scripts.
26  }
27  }
28 
29  public function down() {
30 
31  }
32 }