DoctrineMigrationsBundle
DoctrineMigrationsBundle copied to clipboard
doctrine:migrations:diff generates DROP TABLE for messenger_messages table
After installing Messenger, successive migrations insert "DROP TABLE messenger_messages".
I had the same issue and had to remove the lines by hand but it's fixed for me in the last version
I solved this by ignoring the messenger_messages table in the model using the schema_filter option:
#doctrine.yaml
doctrine:
dbal:
schema_filter: ~^(?!messenger_messages)~
But I'm not sure that this is the solution.
@darielvicedo I think it is! thanks for sharing
The above does not seem to be a solution.
This is on a Docker setup where the SCHEMA is created on docker-compose up --build
as so:
CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION root;
ALTER USER root SET search_path TO test;
Migrations are dropping ALL sequences at each migration:
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP SEQUENCE test.greeting_id_seq CASCADE');
$this->addSql('DROP SEQUENCE test.messenger_messages_id_seq CASCADE');
$this->addSql('ALTER TABLE greeting ADD another_field VARCHAR(255) NOT NULL');
}
AND recreating SCHEMA and SEQUENCE on down
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('CREATE SCHEMA test');
$this->addSql('CREATE SEQUENCE test.greeting_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE test.messenger_messages_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('ALTER TABLE greeting DROP another_field');
}
Note that the issue of dropping SEQUENCES only happens when there's a custom SCHEMA as above. I did not have the same issue when only working with SCHEMA public
. I would still have the CREATE SCHEMA public
on down
. Though I am not sure whether or not that's normal behavior.