29 lines
1,023 B
PHP
29 lines
1,023 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace DoctrineMigrations;
|
||
|
|
|
||
|
|
use Doctrine\DBAL\Schema\Schema;
|
||
|
|
use Doctrine\Migrations\AbstractMigration;
|
||
|
|
|
||
|
|
final class Version20260520060000 extends AbstractMigration
|
||
|
|
{
|
||
|
|
public function getDescription(): string
|
||
|
|
{
|
||
|
|
return 'Cascade delete attribute_values when attribute_definition is deleted';
|
||
|
|
}
|
||
|
|
|
||
|
|
public function up(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql('ALTER TABLE app.attribute_values DROP CONSTRAINT fk_6f6a862d7492f274');
|
||
|
|
$this->addSql('ALTER TABLE app.attribute_values ADD CONSTRAINT fk_6f6a862d7492f274 FOREIGN KEY (attribute_definition_id) REFERENCES app.attribute_definitions (id) ON DELETE CASCADE');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(Schema $schema): void
|
||
|
|
{
|
||
|
|
$this->addSql('ALTER TABLE app.attribute_values DROP CONSTRAINT fk_6f6a862d7492f274');
|
||
|
|
$this->addSql('ALTER TABLE app.attribute_values ADD CONSTRAINT fk_6f6a862d7492f274 FOREIGN KEY (attribute_definition_id) REFERENCES app.attribute_definitions (id)');
|
||
|
|
}
|
||
|
|
}
|