Reputation: 2101
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?
Upvotes: 4
Views: 2296
Reputation: 144
When having multiple connections it needs to be set for each connection:
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
schema_filter: '~^(?!messenger_messages)~'
Upvotes: 2
Reputation: 2101
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:
Thanks @Diabetic Nephropathy for hinting the way with regex.
Upvotes: 5
Reputation: 190
You can find your answer in the docs : https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html#manual-tables
Short answer : add prefix to your custom tables, then configure this prefix (for instance if your custom tables start by 't_') :
doctrine:
dbal:
schema_filter: ~^(?!t_)~
Upvotes: 5