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.
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:And then in each
tearDown
I have:In my migration
up
method I have someINSERT
SQL queries. In mydown
I have onlyDROP TABLE
.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 prevup
function call and later queries fromdown
call.Current behavior
On the
doctrine:migrate first
running in thetearDown
theINSERT
from theup
method executed and after that theDROP TABLE
exectued.How to reproduce
Expected behavior
No SQL quries from the first migrations executed on
migrations:migrate first
, onlyDROP TABLE
noINSERT
.