-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database Migration does set current version in DB #98
Comments
After |
Exec throws an error
|
That works:
|
That would set the new version even if the migration failed I guess 🤔 |
@thePanz It was just a quick fix to get it work ;) The question is: Why this happens: "PDOException: There is no active transaction in xxx". |
This error happens in PHP 8+. See Implicit Commits in PHP8. The problem happens in Migration.php, method "migrate()" (rows 319 to 355). Specifically, row 319 starts a transaction, then does migrations by calling There are several solutions to this problem, depending on how one wants to approach it, but I believe it would be the cleanest to check if a transaction exists after migration and if not, to start a new one, essentially replicating what happens implicitly in PHP 5-7. For example: diff --git a/lib/Doctrine/Migration.php b/lib/Doctrine/Migration.php
index 615c792ec..1d8b0c742 100644
--- a/lib/Doctrine/Migration.php
+++ b/lib/Doctrine/Migration.php
@@ -326,6 +326,9 @@ class Doctrine_Migration
}
$this->_doMigrate($to);
+ if (!$this->_connection->getDbh()->inTransaction()) {
+ $this->_connection->beginTransaction();
+ }
} catch (Exception $e) {
$this->addError($e);
} Note that this means we could perform one migration successfully, fail the second one and be stuck with an incorrect migration version. However, this is already the case, as PHP 5-7 already do this. The correct approach would be to alter the tables in a migration, then update the version, then start the next migration, which would require a refactoring of this method. Side note, this bug may most obviously appear in migrations, but could also happen otherwise, for example if our code calls to create a new table in the database on the fly. |
If u run
php symfony doctrine:migrate
the tash will so the migration_version table to the current version.That does not happen anymore.
The value (version) does not change.
Its in the Doctrine/Migration.php: https://github.com/FriendsOfSymfony1/doctrine1/blob/master/lib/Doctrine/Migration.php#L350
Does not work anymore.
I changed it to:
That works!
The text was updated successfully, but these errors were encountered: