You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the autocommit mode is disabled and save points are enabled, the fixtures cannot be loaded because the wrapInTransaction method from doctrine/orm/src/EntityManager.php begin a transaction without checking first if a transaction is active (which is done automatically when the connection is opened when autocommit is disabled). This is a problem because when save points are enabled because it adds savepoint and the fixtures are therefore never loaded.
Potential solution 1:
If I check if a transaction is active before starting a transaction, it works as expected. E.g. :
Moreover, I figured out that the problem is that a DDL commands (CREATE, ALTER, DROP...) automatically start transactions in MySQL when the autocommit mode is disabled.
Therefore, if an INSERT statement follows a CREATE command, nothing will be inserted because a COMMIT is missing. This causes the last migration to be not inserted even if the potential solution above solves partially the issue.
To be sure the doctrine migrations versions table were up to date, I had to wrap the $this->metadataStorage->complete($result); around $this->connection->transactional(...) in DbalExecutor L185 :
// ...$this->connection->transactional(function () use ($result) {
$this->metadataStorage->complete($result);
});
// ...
Bug Report
Summary
When the autocommit mode is disabled and save points are enabled, the fixtures cannot be loaded because the
wrapInTransaction
method fromdoctrine/orm/src/EntityManager.php
begin a transaction without checking first if a transaction is active (which is done automatically when the connection is opened when autocommit is disabled). This is a problem because when save points are enabled because it adds savepoint and the fixtures are therefore never loaded.Potential solution 1:
If I check if a transaction is active before starting a transaction, it works as expected. E.g. :
Potential solution 2:
Create a dedicated EntityManager for migrations with autocommit disabled 😢
Moreover, I think transactions should not be automatically started or commited as I explained here: doctrine/dbal#6258 (comment)
The text was updated successfully, but these errors were encountered: