SuperSeller3000/migrations/Version20260517222701.php

35 lines
1.5 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260517222701 extends AbstractMigration
{
public function getDescription(): string
{
return 'Promote article_type_attributes join table to entity with id + required flag';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE app.article_type_attributes ADD COLUMN id UUID DEFAULT gen_random_uuid() NOT NULL');
$this->addSql('ALTER TABLE app.article_type_attributes ADD COLUMN required BOOLEAN NOT NULL DEFAULT FALSE');
$this->addSql('ALTER TABLE app.article_type_attributes DROP CONSTRAINT article_type_attributes_pkey');
$this->addSql('ALTER TABLE app.article_type_attributes ADD PRIMARY KEY (id)');
$this->addSql('CREATE UNIQUE INDEX uniq_article_type_attribute ON app.article_type_attributes (article_type_id, attribute_definition_id)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX app.uniq_article_type_attribute');
$this->addSql('ALTER TABLE app.article_type_attributes DROP CONSTRAINT article_type_attributes_pkey');
$this->addSql('ALTER TABLE app.article_type_attributes DROP COLUMN id');
$this->addSql('ALTER TABLE app.article_type_attributes DROP COLUMN required');
$this->addSql('ALTER TABLE app.article_type_attributes ADD PRIMARY KEY (article_type_id, attribute_definition_id)');
}
}