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

After update doctrine/doctrine-bundle to version 1.11.x, migrations not working properly with "schema_filter" option #821

Closed
mleko64 opened this issue May 13, 2019 · 4 comments

Comments

@mleko64
Copy link

mleko64 commented May 13, 2019

Bug Report

Symfony version: 4.2.8

doctrine/doctrine-bundle: 1.11.0
doctrine/dbal: 2.9.2
doctrine/doctrine-migrations-bundle: 2.0.0

Summary

After update "doctrine/doctrine-bundle" from version 1.10.x to 1.11.x, migrations not working properly. I'm using the "schema_filter" option and I realized that this option stops working.

I reviewed the changes and came to the conclusion that the following line should be added to the file "src/Kernel.php" (in "build" method):

$container->addCompilerPass(new DbalSchemaFilterPass());

After that, "schema_filter" option starts working, BUT only from one side (only DB tables are filtered, but entity classes not).
I looked into "migrations/lib/Doctrine/Migrations/Generator/DiffGenerator.php" file and I noticed that in method "createToSchema" (around line 104) is used deprecated method:

$this->dbalConfiguration->getFilterSchemaAssetsExpression()

In my opinion, should be this method (new one):

$this->dbalConfiguration->getSchemaAssetsFilter()

And "if" statment (in "foreach" loop) should be:

 if ($filterExpression($this->resolveTableName($tableName))) {
     continue;
}

When I'm change this two things, everything works perfectly.

Current behavior

Diff command not works properly with "schema_filter" option (only table names are filtered, entity classes not).
I have a entity classes with table name which should not be process while diff changes.

How to reproduce

  1. Update "doctrine/doctrine-bundle" to latest version (1.11.0)
  2. Enable "DbalSchemaFilterPass" in "src/Kernel.php" (in "build" method):
$container->addCompilerPass(new DbalSchemaFilterPass());
  1. Set "schema_filter" option with some pattern (should be not include some entity clases)
  2. Run "bin/console doctrine:migrations:diff"
  3. Review new migration file. File should contains "CREATE" statements for entities which should be ignored.

Expected behavior

"schema_filter" option should be work properly (filtering table names and entity classes).

@bendavies
Copy link
Contributor

@mleko64
Copy link
Author

mleko64 commented May 13, 2019

Thanks for fast response.
Okey, this PR solving one problem - missing compiler pass registration.
What about second problem? In my opinion, method "createToSchema" in file "migrations/lib/Doctrine/Migrations/Generator/DiffGenerator.php" should be fixed.
Now, with new logic of "schema_filter" option, diff process not working properly.
Entity classes are not filtered correctly.

@bendavies - Could you create PR in this project with my suggestions?

@bendavies
Copy link
Contributor

bendavies commented May 13, 2019

hello @mleko64. I raised that PR before you raise this issue - I'm merely linking two related issues together.
If you have a fix in mind to resolve the issue with doctrine/migrations, feel free to have a go at fixing it and raising a PR.

Thanks

@alcaeus
Copy link
Member

alcaeus commented Jul 30, 2019

This was fixed in 2.1.0, closing here.

@alcaeus alcaeus closed this as completed Jul 30, 2019
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

Successfully merging a pull request may close this issue.

3 participants