Skip to content

Commit

Permalink
Added check control to avoid update structure whitout column 'propert…
Browse files Browse the repository at this point in the history
…ies'
  • Loading branch information
Juan Francisco Onielfa Veneros committed Jun 21, 2020
1 parent 4e5c904 commit ef38661
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/dedalo/backup/class.backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public static function copy_from_file($table, $path_file, $tld) {

if (!file_exists($path_file)) {
throw new Exception("Error Processing Request. File $path_file not found", 1);
}
}

$command_history = array();

Expand All @@ -293,6 +293,30 @@ public static function copy_from_file($table, $path_file, $tld) {
switch ($table) {

case 'jer_dd':
// verify target table columns
$check_column_name = 'properties';
$strQuery = "SELECT column_name FROM information_schema.columns WHERE table_name='jer_dd' and column_name='$check_column_name'";
$result = JSON_RecordDataBoundObject::search_free($strQuery);
if(!$result) {
$msg = "Failed Search column_name '$check_column_name'. Error on exec sql query. Please contact with your admin (3)";
if(SHOW_DEBUG===true) {
throw new Exception($msg, 1);
}
debug_log(__METHOD__." ERROR: $msg ".to_string(), logger::ERROR);
return false;
}
while($rows = pg_fetch_assoc($result)) {
$found_column_name = $rows['column_name'];
}
if (empty($found_column_name)) {
$msg = "Column '$check_column_name' not found. Please update your Dédalo version or manually add column '$check_column_name' to table 'jer_dd'";
if(SHOW_DEBUG===true) {
// throw new Exception($msg, 1);
}
debug_log(__METHOD__." ERROR: $msg ".to_string(), logger::ERROR);
return false;
}

# DELETE . Remove previous records
#$strQuery = "DELETE FROM \"jer_dd\" WHERE \"terminoID\" LIKE '{$tld}%'; "; #pg_query(DBi::_getConnection(), $strQuery);
$command = $command_base . " -c \"DELETE FROM \"jer_dd\" WHERE ".'\"terminoID\"'." LIKE '{$tld}%'\" "; # -c "DELETE FROM \"jer_dd\" WHERE \"terminoID\" LIKE 'dd%'"
Expand Down

0 comments on commit ef38661

Please sign in to comment.