Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

doctrine:migrations:diff "--filter-expression" option ignored for $toSchema #84

Closed
iVariable opened this Issue · 8 comments

5 participants

@iVariable

I'm not really sure is it a bug or just my misunderstanding, but when I'm using diff command like:

doctrine:migrations:diff --filter-expression='~^(?!t_)~'

I expected to see all tables not prefixed with "t_" in generated migration. But prefixed tables are in it. This is because "filter-expression" option is applied only for $fromSchema and ignored for $toSchema, which is generated from entities metadata.

A bit confusing, as for me. :)

May be it'll be better to apply filter for all schemas?
For example like this:

$tool = new SchemaTool($em);

$fromSchema = $conn->getSchemaManager()->createSchema();
$toSchema = $tool->getSchemaFromMetadata($metadata);

if ($filterExpr) {
        $tableNames = $toSchema->getTableNames();
    foreach($tableNames as $tableName){
        $tableName = substr( $tableName, strpos($tableName,'.') + 1);
        if( !preg_match( $filterExpr, $tableName ) ){
            $toSchema->dropTable($tableName);
        }
    }
}
@beberlei
Owner

+1, can you open a PR?

@iVariable iVariable referenced this issue from a commit in iVariable/migrations
@iVariable iVariable Fixed filter-expression support in DiffCommand refs #84 f600720
@iVariable

Done

@iVariable iVariable referenced this issue from a commit in iVariable/migrations
@iVariable iVariable Fixed filter-expression support in DiffCommand refs #84 5dffedd
@myxazzz

Something went wrong...

Call to undefined method Doctrine\DBAL\Configuration::getFilterSchemaAssetsExpression() in /doctrine-migrations/lib/Doctrine/DBAL/Migrations/Tools/Console/Command/DiffCommand.php on line 85

DBAL used:

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.6
@beberlei
Owner

too old version of DBAL, you need 2.2 at least

@stefanosala

In a standard Symfony 2.0 I have the same error as @myxazzz due to old version of DBAL.
Is it possible to tag or branch a compatible revision for DBAL 2.1.x?

@myxazzz

I updated DBAL to 2.2.2
seems all ok

@stof stof referenced this issue in doctrine/DoctrineMigrationsBundle
Closed

DoctrineMigrationsBundle for Symfony 2.0.17? #40

@stof
Collaborator

3dd738b readded the support of 2.1.x (without the filter-expression feature for them)

@stof stof closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.