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

$plannedSql shared between commands execution. #1402

Open
R3VoLuT1OneR opened this issue Feb 29, 2024 · 0 comments
Open

$plannedSql shared between commands execution. #1402

R3VoLuT1OneR opened this issue Feb 29, 2024 · 0 comments

Comments

@R3VoLuT1OneR
Copy link

Bug Report

Used version 2.x now after migration to 3.x I am found this problem.
I am using doctrine migration in my PHPUnit test suite.

On each setUp I am running running migration:

migrations:migrate

And then in each tearDown I have:

migrations:migrate first

In my migration up method I have some INSERT SQL queries.
In my down I have only DROP TABLE.

Q A
BC Break yes
Version 3.7.2

Summary

Basically executed queries shared between commands, if we reuse the "Application".

It's happens because migration objects kept in memory and $plannedSql is not clear between commands execution.
So migration executor appends new queries from down function to $plannedSql and then executes queries from prev up function call and later queries from down call.

Current behavior

On the doctrine:migrate first running in the tearDown the INSERT from the up method executed and after that the DROP TABLE exectued.

How to reproduce

$configuration = new Configuration();
$configuration->addMigrationsDirectory(
    'App\Migrations',
    __DIR__ . '/migrations'
);

$dependencyFactory = DependencyFactory::fromConnection(
    configurationLoader: new ExistingConfiguration($configuration),
    connectionLoader: new ExistingConnection(static::connection()),
);

$migrationsApplication = ConsoleRunner::createApplication(
    dependencyFactory: $dependencyFactory
);

$migrationsApplication->setAutoExit(false);

// Migration
$migrationsApplication->run(new StringInput('migrations:migrate --no-interaction'));

// Rollback
$migrationsApplication->run(new StringInput('migrations:migrate first --no-interaction'));

Expected behavior

No SQL quries from the first migrations executed on migrations:migrate first, only DROP TABLE no INSERT.

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

1 participant