Odyssey
2018090700_lnappSessionAcct.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 lnappSessionAcct extends AbstractMigration {
11  public function up() {
12 
13  // ** Add the column session_account to the lnappuser table
14  // ** this column will indicate the MIR information to load for a user
15 
16  // check if we already made the change
17  $tableName = "lnappuser";
18 
19  if ($this->hasTable($tableName)) {
20  $table = $this->table( $tableName );
21 
22  $hasColumn = $table->hasColumn('session_account');
23 
24  // Test for the existence of the column
25  if ( !$hasColumn ) {
26  print "Upgrade {$tableName}.\n";
27 
28  // Add column
29  $this->query("alter table $tableName add column session_account character varying");
30  }
31  }
32 
33  } // End "up" function.
34 
35  public function down() {
36  } // End "down" function
37 }