$this->loadIniFiles();
$this->updateTableComments();
-
- $this->updateCharacterSet();
-
+
$ff = HTML_FlexyFramework::get();
if (!empty($ff->Pman['enable_trigger_tests'])) {
IF (@DISABLE_TRIGGER IS NULL AND @DISABLE_TRIGGER_{$tbl} IS NULL ) THEN
";
+ $has_checks= false;
+ $errs = array();
foreach($map as $source_col=>$target) {
// check that source_col exists in schema.
if (!isset($this->schema[$tbl][$source_col])) {
+ $errs[] = "SOURCE MISSING: $source_col => $target";
continue;
}
if (!isset($this->schema[$target_table])) {
// skip... target table does not exist
+ $errs[] = "TARGET MISSING: $source_col => $target";
continue;
}
END IF;
";
-
+ $has_checks= true;
}
+
$ar = $this->listTriggerFunctions($tbl, 'insert');
foreach($ar as $fn=>$col) {
$trigger .= "
CALL $fn( NEW.{$col});
";
+ $has_checks= true;
}
$trigger .= "
END
";
+
+ if (!$has_checks) {
+ echo "SKIP TRIGGER {$tbl}_before_insert (missing " . implode(", ", $errs) . ")\n";
+ continue;
+ }
//echo $trigger; exit;
//DB_DAtaObject::debugLevel(1);
$q = DB_DataObject::factory('core_enum');
IF (@DISABLE_TRIGGER IS NULL AND @DISABLE_TRIGGER_{$tbl} IS NULL ) THEN
";
+ $has_checks= false;
+ $err = array();
foreach($map as $source_col=>$target) {
// check that source_col exists in schema.
if (!isset($this->schema[$tbl][$source_col])) {
+ $err[] = "SOURCE MISSING: $source_col => $target";
continue;
}
if (!isset($this->schema[$target_table])) {
// skip... target table does not exist
+ $err[] = "TARGET MISSING: $source_col => $target";
continue;
}
END IF;
";
+ $has_checks= true;
}
$ar = $this->listTriggerFunctions($tbl, 'update');
foreach($ar as $fn=>$col) {
$trigger .= "
CALL $fn(OLD.{$col}, NEW.{$col});
";
+ $has_checks= true;
}
$trigger .= "
END
";
+ if (!$has_checks) {
+ echo "SKIP TRIGGER {$tbl}_before_update (missing " . implode(", ", $err) . ")\n";
+ return;
+ }
+
//echo $trigger; exit;
//DB_DAtaObject::debugLevel(1);
$q = DB_DataObject::factory('core_enum');
return $ret;
}
- function updateCharacterSet()
- {
- foreach (array_keys($this->schema) as $tbl){
-
- if(strpos($tbl, '__keys') !== false ){
- continue;
- }
-
- $ce = DB_DataObject::factory('core_enum');
-
- $ce->query("
- SELECT
- CCSA.character_set_name csname,
- CCSA.collation_name collatename
- FROM
- information_schema.`TABLES` T,
- information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
- WHERE
- CCSA.collation_name = T.table_collation
- AND
- T.table_schema = '{$ce->database()}' -- COLLATE utf8_unicode_ci
- AND
- T.table_name = '{$tbl}' -- COLLATE utf8_unicode_ci
- ");
-
- $ce->fetch();
-
- if($ce->csname == 'utf8' && $ce->collatename == 'utf8_unicode_ci'){
- echo "$tbl is Already utf8 \n";
- continue;
- }
-
- $ce = DB_DataObject::factory('core_enum');
- $ce->query("ALTER TABLE {$tbl} CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci");
- echo "FIXED utf8 on {$tbl}\n";
-
- }
- }
+
}