-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
"There is no active transaction" error after successfully performing migrations #393
Comments
I've just experienced this now myself on PHP v8.0.0. Executing migrations on PHP 8 currently does not work, however I believe it likely relates to Package versions
|
A temporary workaround would be to override |
Duplicate of doctrine/migrations#1104 |
IF YOU STILL GET THIS ERROR if you use Doctrine Migrations Bundle
if you use Doctrine Migrations directly, without bundle, as prompted by @azjezz
|
@yyaremenko the proposed solution works even if you are using the bundle, the bug is in the doctrine/migrations lib, not the bundle :) |
@azjezz yes, I agree and I understand, but the idea with the bundle is that you don't require the library directly in your composer.json; if I use your solution while using bundle, I get the following in my composer.json
The things may get messy quite fast. |
I started to get this error too (since I migrated to PHP 8), but I don't use doctrine migrations. <?php
/** @var \Doctrine\DBAL\Connection $connection */
$connection->beginTransaction();
$connection->executeStatement('SET FOREIGN_KEY_CHECKS=0;');
$connection->executeStatement($sql);
$connection->executeStatement('SET FOREIGN_KEY_CHECKS=1;');
$connection->commit(); Is there a place in Doctrine where I can look for? |
I think you might be able to reproduce it in pure PDO too. If that's true, you will understand that there is not much we can do. |
I see. Is there any issue elsewhere I can follow? |
I don't think there is anything to follow, because there is nothing we should do IMO. You can get an in-depth explanation about implicit commits here though: https://github.com/doctrine/migrations/pull/1157/files |
Thank @greg0ire. I solved by splitting my sql (one with table deletion/creation and one with everything else) |
Hi, maybe is not the correct solution or the one that everyone wants, but you can use PDO directly with DDL and run exec() (AS A TEMPORARY SOLUTION).
And there will be no "There is no active transaction" error code. I'm using php 8.1 and Symfony 6.0.3 You can outwit me or be upset and say "this is an antipattern", but it works. |
Well it does work if you have one statement, but as soon as you have 2 of them, is no longer does. As for the outwitting, if you use MySQL or Oracle, that means you cannot use DDL in a transaction, so… maybe, you know, just don't? |
@greg0ire would a PR adding the option (Mb, I saw it's already done, just not compatible with dbal 2.x 🙈 ) |
Problem
When performing migrations, the process ends with "There is no active transaction" thrown in
Connection.php
on line 1761. The migrations themselves are performed successfully: the database schema appears to be altered as expected, and when re-running migrations Doctrine is aware that all migrations have been run successfully previously already.The problem occurred for the first time after the migration from PHP 7.4 to 8.0.0.
The problem occurs when performing migrations through the
doctrine:migrations:migrate
command, as well as when performed in code by dama/doctrine-test-bundle.Update 2021-01-05
This may be a pdo_mysql issue. See https://twitter.com/derrabus/status/1346405883429924870
Package versions
Related issues
The text was updated successfully, but these errors were encountered: