Skip to content
Snippets Groups Projects
Commit 35e43438 authored by Demian Katz's avatar Demian Katz
Browse files

Fixed bug -- missing column detection did not work.

parent 9c7d45bd
No related merge requests found
......@@ -291,6 +291,27 @@ class DbUpgrade extends AbstractPlugin
return $type == $expectedType;
}
/**
* Support method for getModifiedColumns() -- check if the current column is
* in the missing column list so we can avoid modifying something that does
* not exist.
*
* @param string $column Column to check
* @param string $missing Missing column list for column's table.
*
* @return bool
*/
public function columnIsMissing($column, $missing)
{
foreach ($missing as $current) {
preg_match('/^\s*`([^`]*)`.*$/', $current, $matches);
if ($column == $matches[1]) {
return true;
}
}
return false;
}
/**
* Get a list of changed columns in the database tables (associative array,
* key = table name, value = array of column name => new data type).
......@@ -335,7 +356,9 @@ class DbUpgrade extends AbstractPlugin
$actualColumns = $this->getTableColumns($table);
foreach ($expectedColumns as $i => $column) {
// Skip column if we're logging and it's missing
if (in_array($column, $missingColumns)) {
if (isset($missingColumns[$table])
&& $this->columnIsMissing($column, $missingColumns[$table])
) {
continue;
}
$currentColumn = $actualColumns[$column];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment