7 use Phinx\Migration\AbstractMigration;
18 $columnsToCheck= array(
19 array(
"table" =>
"cuauditadmin",
"column" =>
"user_name"),
20 array(
"table" =>
"cuadmeco",
"column" =>
"admin"),
21 array(
"table" =>
"cuadminallow",
"column" =>
"user_name"),
22 array(
"table" =>
"cuadminexclude",
"column" =>
"user_name"),
23 array(
"table" =>
"cuadminusers",
"column" =>
"user_name")
27 foreach($columnsToCheck as $colArray)
29 $column= $colArray[
"column"];
30 $table= $colArray[
"table"];
31 $sql[]=
"(select coalesce(bool_or($column != lower($column)), false) from $table) as $table";
35 $sql=
"select " . implode(
",", $sql);
36 $row= $this->fetchRow($sql);
40 foreach($columnsToCheck as $colArray)
42 if ($row[$colArray[
"table"]])
50 print
"All username values are already lowercase. Nothing is done.\n";
53 foreach($columnsToCheck as $colArray)
55 $column= $colArray[
"column"];
56 $table= $colArray[
"table"];
59 print
"Changing usernames in table $table...\n";
60 $sql=
"update $table set $column = lower($column) where $column != lower($column)";
73 public function down()
75 print
"Not implementing the 'down'";