Sqlite migrations should have foreign keys disabled outside the transaction
Existing behavior could lead to data loss if schema is changed.
This commit is contained in:
committed by
fguillot
parent
aad436d219
commit
fdbbb29cd6
@@ -93,8 +93,8 @@ class Schema
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
for ($i = $current_version + 1; $i <= $next_version; $i++) {
|
for ($i = $current_version + 1; $i <= $next_version; $i++) {
|
||||||
$this->db->startTransaction();
|
|
||||||
$this->db->getDriver()->disableForeignKeys();
|
$this->db->getDriver()->disableForeignKeys();
|
||||||
|
$this->db->startTransaction();
|
||||||
|
|
||||||
$function_name = $this->getNamespace().'\version_'.$i;
|
$function_name = $this->getNamespace().'\version_'.$i;
|
||||||
|
|
||||||
@@ -104,8 +104,8 @@ class Schema
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->db->getDriver()->setSchemaVersion($i);
|
$this->db->getDriver()->setSchemaVersion($i);
|
||||||
$this->db->getDriver()->enableForeignKeys();
|
|
||||||
$this->db->closeTransaction();
|
$this->db->closeTransaction();
|
||||||
|
$this->db->getDriver()->enableForeignKeys();
|
||||||
}
|
}
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
$this->db->setLogMessage($e->getMessage());
|
$this->db->setLogMessage($e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user