doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 387 forks source link

`CREATE SCHEMA public` is added to all down migrations in Postgres #1415

Open speller opened 4 months ago

speller commented 4 months ago

Bug Report

Q A
Version 3.8.3

Summary

I'm using the bundle with Postrgres 16. The database URL is postgresql://$DB_USER:$DB_PASSWORD@db:5432/$DB_NAME?serverVersion=16.2&charset=utf8. But on every doctrine:migrations:diff it creates migrations like the following:

final class Version20240311103945 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs

    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE SCHEMA public');
    }
}

No matter what are other changes, it ALWAYS adds the $this->addSql('CREATE SCHEMA public'); line to all migrations.

How to fix it?

maluramichael commented 3 months ago

We got the exact same problem. Dont know how to work around it :/

greg0ire commented 3 months ago

Related to https://github.com/doctrine/dbal/issues/5609 and https://github.com/doctrine/dbal/issues/1110 I think.

ramsey commented 1 month ago

I'm having this problem, too. I've been manually removing the line because it causes errors when attempting to roll back to a previous migration.