45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace DoctrineMigrations;
|
||
|
|
|
||
|
|
use Doctrine\DBAL\Schema\Schema;
|
||
|
|
use Doctrine\Migrations\AbstractMigration;
|
||
|
|
|
||
|
|
final class Version20260520100000 extends AbstractMigration
|
||
|
|
{
|
||
|
|
public function getDescription(): string
|
||
|
|
{
|
||
|
|
return 'Replace ebay_aspect_field_mappings JSON with article_type_ebay_mappings table';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function up(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql("
|
||
|
|
CREATE TABLE app.article_type_ebay_mappings (
|
||
|
|
id UUID NOT NULL,
|
||
|
|
article_type_id UUID NOT NULL,
|
||
|
|
ebay_aspect_name VARCHAR(255) NOT NULL,
|
||
|
|
source_type VARCHAR(30) NOT NULL,
|
||
|
|
article_field_key VARCHAR(100) DEFAULT NULL,
|
||
|
|
attribute_definition_id UUID DEFAULT NULL,
|
||
|
|
required BOOLEAN NOT NULL DEFAULT FALSE,
|
||
|
|
PRIMARY KEY (id),
|
||
|
|
UNIQUE (article_type_id, ebay_aspect_name),
|
||
|
|
CONSTRAINT fk_etm_article_type FOREIGN KEY (article_type_id)
|
||
|
|
REFERENCES app.article_types (id) ON DELETE CASCADE,
|
||
|
|
CONSTRAINT fk_etm_attr_def FOREIGN KEY (attribute_definition_id)
|
||
|
|
REFERENCES app.attribute_definitions (id) ON DELETE SET NULL
|
||
|
|
)
|
||
|
|
");
|
||
|
|
$this->addSql("ALTER TABLE app.article_types DROP COLUMN IF EXISTS ebay_aspect_field_mappings");
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql("DROP TABLE app.article_type_ebay_mappings");
|
||
|
|
$this->addSql("ALTER TABLE app.article_types ADD COLUMN ebay_aspect_field_mappings JSON DEFAULT NULL");
|
||
|
|
}
|
||
|
|
}
|