Is there a way to tell doctrine not to touch specific tables?

Viewed 637

Every time I run doctrine:migrations:diff to generate migration for my changes it always includes removal of a few tables that are not handled by doctrine eg.:

$this->addSql('DROP TABLE messenger_messages');
$this->addSql('DROP TABLE monitoring');

Is there a way to tell doctrine that specific tables do not belong to him so doctrine will stop trying to drop them every time?

2 Answers

You can use a regex to exclude tables from doctrine field of view. To specify a list of tables that should not be touched by doctrine just add this to config:

doctrine:
  dbal:
    schema_filter: ~^(?!(messenger_messages|monitoring|foo|bar)$)~

This will prevent doctrine from manipulating those four tables:

  • messenger_messages
  • monitoring
  • foo
  • bar

Thanks @Diabetic Nephropathy for hinting the way with regex.

Related