Home > database >  Ignore entity when generating a migration on Symfony
Ignore entity when generating a migration on Symfony

Time:12-19

I have a mysql view and I am using it as an entity inside my project. But when generating a migration it tries to create a table. Is there a way to tell symfony to ignore that entity when generating a new migration?

/**
 * @ORM\Entity
 * @ORM\Table(name="mysql_view_table")
 */
class MysqlViewTable {}

CodePudding user response:

The feature is ready (actually was merged 5 days ago), but not released yet. It will be included in the next (2.11) version. You will have option to set a list of entities to be ignored in the configuration:

$config->setSchemaIgnoreClasses([$fqcn]);

Docs: https://www.doctrine-project.org/projects/doctrine-orm/en/2.11/reference/advanced-configuration.html#ignoring-entities-optional

PR: https://github.com/doctrine/orm/pull/9202

CodePudding user response:

You can use this configuration to ignore the table mysql_view_table:

doctrine:
    dbal:
        schema_filter: ~^(?!mysql_view_table)~

For more information, you can visite DoctrineMigrationsBundle doc:

  • Related