Skip to content
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

doctrine-migrations-bundle with --all-or-nothing option and doctrine/dbal 3.* lead to "There is no active transaction" error #1204

Closed
dimadeush opened this issue Oct 17, 2021 · 1 comment

Comments

@dimadeush
Copy link

Bug Report

Q A
BC Break no
Version 3.*

Summary

PHP 8.0.11, Symfony 5.3., doctrine/orm 2.10., doctrine/doctrine-migrations-bundle 3.1., doctrine/dbal 3.1.
next cmd "php bin/console doctrine:migrations:migrate --no-interaction --all-or-nothing" command lead to "There is no active transaction" (In Connection.php line 136: ) error and in case I have only one migration with DDL, f.e.:
`public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() !== 'mysql',
'Migration can only be executed safely on 'mysql'.'
);

    $sql = <<<SQL

CREATE TABLE scheduled_command (
id INT AUTO_INCREMENT NOT NULL,
name VARCHAR(150) NOT NULL,
command VARCHAR(200) NOT NULL,
arguments LONGTEXT DEFAULT NULL,
cron_expression VARCHAR(200) DEFAULT NULL,
last_execution DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)',
last_return_code INT DEFAULT NULL,
log_file VARCHAR(150) DEFAULT NULL,
priority INT NOT NULL,
execute_immediately TINYINT(1) NOT NULL,
disabled TINYINT(1) NOT NULL,
locked TINYINT(1) NOT NULL,
version INT DEFAULT 1 NOT NULL,
created_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime)',
UNIQUE INDEX UNIQ_EA0DBC905E237E06 (name),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB
SQL;

    $this->addSql($sql);

    $this->addSql('ALTER TABLE scheduled_command ');
}`

As a workaround I can run cmd command without option "--all-or-nothing" and in case "all_or_nothing: false" in doctrine_migrations.yaml and in case this transaction marked as "isTransactional() -> false". But in such case I can't run migrations with option --all-or-nothing and if I have migrations with DML.
If I downgrading doctrine/dbal to 2.13.4 - everything fine and there is no such error.

P.S. Or maybe it can be related to bundle doctrine/doctrine-migrations-bundle and it should require doctrine/doctrine-bundle: ~1.0|2.1.0

@greg0ire greg0ire transferred this issue from doctrine/dbal Oct 18, 2021
@greg0ire
Copy link
Member

Duplicate of #1202

@greg0ire greg0ire marked this as a duplicate of #1202 Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants