|
|
@ -82,29 +82,35 @@ class Db_Migrations {
|
|
|
|
else
|
|
|
|
else
|
|
|
|
Debug::log("Starting migration to $version...", Debug::LOG_VERBOSE);
|
|
|
|
Debug::log("Starting migration to $version...", Debug::LOG_VERBOSE);
|
|
|
|
|
|
|
|
|
|
|
|
// mysql doesn't support transactions for DDL statements
|
|
|
|
$lines = $this->get_lines($version);
|
|
|
|
if (Config::get(Config::DB_TYPE) != "mysql")
|
|
|
|
|
|
|
|
$this->pdo->beginTransaction();
|
|
|
|
if (count($lines) > 0) {
|
|
|
|
|
|
|
|
// mysql doesn't support transactions for DDL statements
|
|
|
|
foreach ($this->get_lines($version) as $line) {
|
|
|
|
if (Config::get(Config::DB_TYPE) != "mysql")
|
|
|
|
Debug::log($line, Debug::LOG_EXTENDED);
|
|
|
|
$this->pdo->beginTransaction();
|
|
|
|
try {
|
|
|
|
|
|
|
|
$this->pdo->query($line);
|
|
|
|
foreach ($lines as $line) {
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
Debug::log($line, Debug::LOG_EXTENDED);
|
|
|
|
Debug::log("Failed on line: $line", Debug::LOG_VERBOSE);
|
|
|
|
try {
|
|
|
|
throw $e;
|
|
|
|
$this->pdo->query($line);
|
|
|
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
|
|
|
|
Debug::log("Failed on line: $line", Debug::LOG_VERBOSE);
|
|
|
|
|
|
|
|
throw $e;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($version == 0 && $this->base_is_latest)
|
|
|
|
if ($version == 0 && $this->base_is_latest)
|
|
|
|
$this->set_version($this->get_max_version());
|
|
|
|
$this->set_version($this->get_max_version());
|
|
|
|
else
|
|
|
|
else
|
|
|
|
$this->set_version($version);
|
|
|
|
$this->set_version($version);
|
|
|
|
|
|
|
|
|
|
|
|
if (Config::get(Config::DB_TYPE) != "mysql")
|
|
|
|
if (Config::get(Config::DB_TYPE) != "mysql")
|
|
|
|
$this->pdo->commit();
|
|
|
|
$this->pdo->commit();
|
|
|
|
|
|
|
|
|
|
|
|
Debug::log("Migration finished, current version: " . $this->get_version(), Debug::LOG_VERBOSE);
|
|
|
|
Debug::log("Migration finished, current version: " . $this->get_version(), Debug::LOG_VERBOSE);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Debug::log("Migration failed: schema file is empty or missing.", Debug::LOG_VERBOSE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
Debug::log("Migration failed: " . $e->getMessage(), Debug::LOG_VERBOSE);
|
|
|
|
Debug::log("Migration failed: " . $e->getMessage(), Debug::LOG_VERBOSE);
|
|
|
|