migrations: refuse to apply empty schema files
This commit is contained in:
parent
4ede76280b
commit
8f8ca49e4b
|
@ -82,11 +82,14 @@ class Db_Migrations {
|
|||
else
|
||||
Debug::log("Starting migration to $version...", Debug::LOG_VERBOSE);
|
||||
|
||||
$lines = $this->get_lines($version);
|
||||
|
||||
if (count($lines) > 0) {
|
||||
// mysql doesn't support transactions for DDL statements
|
||||
if (Config::get(Config::DB_TYPE) != "mysql")
|
||||
$this->pdo->beginTransaction();
|
||||
|
||||
foreach ($this->get_lines($version) as $line) {
|
||||
foreach ($lines as $line) {
|
||||
Debug::log($line, Debug::LOG_EXTENDED);
|
||||
try {
|
||||
$this->pdo->query($line);
|
||||
|
@ -105,6 +108,9 @@ class Db_Migrations {
|
|||
$this->pdo->commit();
|
||||
|
||||
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) {
|
||||
Debug::log("Migration failed: " . $e->getMessage(), Debug::LOG_VERBOSE);
|
||||
|
|
Loading…
Reference in New Issue