-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations diff and postgres schema problem with recreating existing tables #7652
Comments
Seems very similar to doctrine/dbal#3482 Can you maybe chat with the original author of that table to see if you can reduce it to either a DBAL or an ORM test case? |
@Ocramius I'm not sure that issue is similar to mine. He's using MySQL and multiple database, I use Postgres and it's schema. I found simlar cases here and here. I also found notice in Doctrine API documentation
Is even Doctrine able to work with Postgres schemas? |
Same problem here ! |
@flolivaud For now I'm not using schema annotation in entities. This solves the problem about recreating tables but every time on diff command Doctrine is trying to create public function down(Schema $schema)
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
... Fortunately I don't need to use other schemas in psql at least for now. It's pretty old issue. For (some) solution look here and here |
Already using this solution since the beginning of my app. But i think it's not the same issue. |
@flolivaud I think it's exactly the same issue, look at DBAL-1168 and comment 352177498 :) I'd issues with auto generated FK constraints too as it described here. I've to use modified Doctrine sources (or write migrations manually). |
@seticzech it's not the only issue for me. <?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190326205509 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
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE TABLE "user"."user" (id UUID DEFAULT uuid_generate_v4() NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX uniq_33a053ffe7927c74 ON "user"."user" (email)');
$this->addSql('COMMENT ON COLUMN "user"."user".id IS \'(DC2Type:uuid)\'');
$this->addSql('DROP TABLE "user"."user"');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE TABLE "user"."user" (id UUID DEFAULT \'uuid_generate_v4()\' NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX uniq_33a053ffe7927c74 ON "user"."user" (email)');
$this->addSql('COMMENT ON COLUMN "user"."user".id IS \'(DC2Type:uuid)\'');
$this->addSql('DROP TABLE "user"."user"');
}
} Removing quote around |
@flolivaud Wow :D I'm trying to understand what is going on... but it's completely mess. Is this unmodified auto generated migration? |
@seticzech yes it is ! :). Honestly i think postgresql should not be "officialy" supported by doctrine/dbal (or doctrine/orm). |
Well, write tests then :-P |
@seticzech Hey, Do you have any news about it please ? :) |
@Cupkek05 I haven't. Is it still occured? I didn't use Doctrine for some time and I noticed version 3 is out. |
I'm still have the same problem on a similar situation |
I "fixed" this issue with separating the entitites from different schemas. Every schema has its own configuration, entity manager and migration files. |
any update? i have the same problem.. |
Bug Report
Summary
Running
doctrine:migrations:diff
multiple times without any changes and with existing table in database always generate the same code trying to create table with schema and delete the very same table without schema.How to reproduce
On any project create entity:
Run
doctrine:migrations:diff
Generated migration is ok now:
Run
doctrine:migrations:migrate
and table is created succesfully in database.Run
doctrine:migrations:diff
again and new migration is generated:Of course next running
doctrine:migrations:migrate
ends with errorExpected behavior
I think expected behavior is clear here - don't create new migrations when nothing was changed.
The text was updated successfully, but these errors were encountered: