8 use Phinx\Migration\AbstractMigration;
11 public function up() {
13 $cuList = $this->fetchAll(
'SELECT cu FROM cuadmin');
16 foreach ($cuList as $cuRow) {
17 $cu = strtolower(trim($cuRow[
"cu"]));
18 $cuTableExists = $this->hasTable($cu .
"transdtl");
21 $this->query(
"ALTER TABLE {$cu}transdtl ALTER COLUMN email_notify DROP DEFAULT");
22 $this->query(
"ALTER TABLE {$cu}transdtl ALTER COLUMN email_notify TYPE smallint USING CASE WHEN email_notify=TRUE THEN 1 ELSE 0 END");
23 $this->query(
"ALTER TABLE {$cu}transdtl ALTER COLUMN email_notify SET DEFAULT 0");
28 public function down() {
30 $cuList = $this->fetchAll(
'SELECT cu FROM cuadmin');
33 foreach ($cuList as $cuRow) {
34 $cu = strtolower(trim($cuRow[
"cu"]));
35 $cuTableExists = $this->hasTable($cu .
"transdtl");
38 $this->query(
"ALTER TABLE {$cu}transdtl ALTER COLUMN email_notify DROP DEFAULT");
39 $this->query(
"ALTER TABLE {$cu}transdtl ALTER COLUMN email_notify TYPE bool USING CASE WHEN email_notify=0 THEN FALSE ELSE TRUE END");
40 $this->query(
"ALTER TABLE {$cu}transdtl ALTER COLUMN email_notify SET DEFAULT FALSE");