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

Invalid orm schema handling after migration from test bundle 1.x -> 3.x and multiple entity managers #30

Closed
scaytrase opened this issue Jul 15, 2019 · 5 comments

Comments

@scaytrase
Copy link

scaytrase commented Jul 15, 2019

We use postgres and manage our database schema with custom migrations, not with schema tool (schema:update)

We have two separate connections and EMs pointing (for tests for sure) to the same database (using different sets of tables)

For the 1.x branch database structure was only purged for SQLite DB driver, so we have no issues

https://github.com/liip/LiipFunctionalTestBundle/blob/45cac28b3fafeb75aebc58c4a2cf74dd1e093569/Test/WebTestCase.php#L403-L449

But after migrating to 3.x with fixtures bundle (and I confirmed 2.x had the same code) schema is updated forcibly either with drop/create or update schema tool.

https://github.com/liip/LiipFunctionalTestBundle/blob/7b4e40176c8a4fb359f28c27b1f71d33296a6aa9/src/Services/DatabaseTools/ORMDatabaseTool.php#L122-L132

// TODO: handle case when using persistent connections. Fail loudly?
$schemaTool = new SchemaTool($this->om);
if (count($this->excludedDoctrineTables) > 0 || true === $append) {
if (!empty($this->getMetadatas())) {
$schemaTool->updateSchema($this->getMetadatas());
}
} else {
$schemaTool->dropDatabase();
if (!empty($this->getMetadatas())) {
$schemaTool->createSchema($this->getMetadatas());
}
}

Since we have two EMs and two connection we got a strange situation while loading all sets of fixtures for both:

first EM drops the whole database and restores only own metadatas.
Same does the second

We result with non-consistent database setup where not all tables present, thus tests fail

@scaytrase scaytrase changed the title Invalid schema handling after migration from test bundle 1.x -> 3.x and multiple entity managers Invalid orm schema handling after migration from test bundle 1.x -> 3.x and multiple entity managers Jul 15, 2019
@scaytrase
Copy link
Author

I hope #15 will fix it. Will try and report

@scaytrase
Copy link
Author

Yep, It helps

@alexislefebvre
Copy link
Collaborator

Please try last release: https://github.com/liip/LiipTestFixturesBundle/releases/tag/1.1.0

@scaytrase
Copy link
Author

Looks good

@alexislefebvre
Copy link
Collaborator

Thanks for the tests!

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