Skip to content

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

Closed
iVariable opened this Issue Aug 14, 2012 · 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
Doctrine member

+1, can you open a PR?

@iVariable iVariable added a commit to iVariable/migrations that referenced this issue Aug 16, 2012
@iVariable iVariable Fixed filter-expression support in DiffCommand refs #84 f600720
@iVariable

Done

@iVariable iVariable added a commit to iVariable/migrations that referenced this issue Sep 7, 2012
@iVariable iVariable Fixed filter-expression support in DiffCommand refs #84 5dffedd
@myxazzz
myxazzz commented Sep 11, 2012

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
Doctrine member

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
myxazzz commented Sep 12, 2012

I updated DBAL to 2.2.2
seems all ok

@stof stof referenced this issue in doctrine/DoctrineMigrationsBundle Sep 13, 2012
Closed

DoctrineMigrationsBundle for Symfony 2.0.17? #40

@stof
Doctrine member
stof commented Sep 20, 2012

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

@stof stof closed this Sep 20, 2012
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.