17 function addBooleanColumnTo($dbManager, $tableName, $columnName =
'is_enabled')
19 echo
"Migrate: Add and setup column=$columnName to table=$tableName\n";
20 if (! $dbManager->existsColumn($tableName, $columnName))
22 $dbManager->queryOnce(
"ALTER TABLE $tableName
23 ADD COLUMN $columnName BOOLEAN;");
26 $dbManager->queryOnce(
"UPDATE $tableName
27 SET $columnName = " . $tableName .
"_pk IN
28 (SELECT MAX(" . $tableName .
"_pk) AS enabled_pk
30 GROUP BY pfile_fk);");
31 $dbManager->queryOnce(
"ALTER TABLE $tableName
32 ALTER COLUMN $columnName
34 $dbManager->queryOnce(
"ALTER TABLE $tableName
35 ALTER COLUMN $columnName
39 foreach (array(
'copyright',
'ecc') as $name)
42 addBooleanColumnTo($dbManager, $name.
'_decision');