7 use Phinx\Migration\AbstractMigration;
18 $cuList = $this->fetchAll(
'SELECT cu FROM cuadmin');
20 for ( $i = 0; $i < count( $cuList ); $i++ ) {
21 $cu = strtolower( trim( $cuList[$i][
"cu"] ) );
24 $tableName =
"{$cu}transhdr";
25 $table = $this->table( $tableName );
26 $hasColumn = $table->hasColumn(
'approved_status');
31 print
"Converting $cu {$tableName}\n";
34 $sql =
"CREATE TABLE {$cu}transhdrtemp ( 35 id SERIAL PRIMARY KEY, 36 feature_code character varying(10) NOT NULL, 39 posted_date timestamp without time zone, 41 approved_date timestamp without time zone, 42 approved_status smallint, 43 processed_by character varying(50), 44 processed_date timestamp without time zone, 45 processed_status smallint, 46 accountnumber character(12), 47 accounttype character(12), 48 deposittype character(1), 49 transactioncode character(2), 50 memo character varying(255) 54 $rows = $this->query( $sql );
57 $sql =
"COMMENT ON COLUMN {$cu}transhdrtemp.feature_code is 'Same feature code as menuing'";
58 $rows = $this->query( $sql );
60 $sql =
"COMMENT ON COLUMN {$cu}transhdrtemp.approved_status is 'Approved(10) or cancelled(99)'";
61 $rows = $this->query( $sql );
63 $sql =
"COMMENT ON COLUMN {$cu}transhdrtemp.processed_status is 'Waiting(0), Approved/in-batch(10), Emailed(20), or cancelled(99)';";
64 $rows = $this->query( $sql );
67 $sql =
"INSERT INTO {$cu}transhdrtemp 68 (id, feature_code, effective_date, 69 posted_by, posted_date, approved_by, approved_date, 70 accountnumber, accounttype, 71 deposittype, transactioncode, memo) 72 SELECT id, feature_code, effective_date date, 73 posted_by, posted_date, approved_by, approved_date, 74 accountnumber, accounttype, 75 deposittype, transactioncode, memo FROM $tableName";
78 $count = $this->execute( $sql );
80 print
"$count row(s) copied from existing $tableName";
83 $this->dropTable( $tableName );
86 $table = $this->table(
"{$cu}transhdrtemp" );
87 $table->rename( $tableName );
97 public function down()
100 $cuList = $this->fetchAll(
'SELECT cu FROM cuadmin');
102 for ( $i = 0; $i < count( $cuList ); $i++ ) {
103 $cu = strtolower( trim( $cuList[$i][
"cu"] ) );
106 $tableName =
"{$cu}transhdr";
107 $table = $this->table( $tableName );
108 $hasColumn = $table->hasColumn(
'approved_status');
113 print
"Reverting $cu {$tableName}\n";
116 $sql =
"ALTER TABLE $tableName ALTER COLUMN processed_by TYPE integer USING processed_by::integer";
117 $rows = $this->query( $sql );
120 $table->removeColumn(
'processed_status')
122 $table->removeColumn(
'approved_status')