<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260807160000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add road_occupation_stage_purpose_fee for dynamic occupation purpose fees per stage (#29749).';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE road_occupation_stage_purpose_fee (
id UUID NOT NULL,
stage_id UUID NOT NULL,
purpose_fee_id UUID NOT NULL,
width DOUBLE PRECISION DEFAULT NULL,
length DOUBLE PRECISION DEFAULT NULL,
area DOUBLE PRECISION DEFAULT NULL,
ordinal_number INT DEFAULT NULL,
created_by UUID DEFAULT NULL,
updated_by UUID DEFAULT NULL,
created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
PRIMARY KEY(id)
)');
$this->addSql('CREATE INDEX IDX_ROSPF_STAGE ON road_occupation_stage_purpose_fee (stage_id)');
$this->addSql('CREATE INDEX IDX_ROSPF_PURPOSE_FEE ON road_occupation_stage_purpose_fee (purpose_fee_id)');
$this->addSql('CREATE INDEX IDX_ROSPF_CREATED_BY ON road_occupation_stage_purpose_fee (created_by)');
$this->addSql('CREATE INDEX IDX_ROSPF_UPDATED_BY ON road_occupation_stage_purpose_fee (updated_by)');
$this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.stage_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.purpose_fee_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.created_by IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.updated_by IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee ADD CONSTRAINT FK_ROSPF_STAGE FOREIGN KEY (stage_id) REFERENCES road_occupation_stage (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee ADD CONSTRAINT FK_ROSPF_PURPOSE_FEE FOREIGN KEY (purpose_fee_id) REFERENCES dict_road_occupation_purpose_fee (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee ADD CONSTRAINT FK_ROSPF_CREATED_BY FOREIGN KEY (created_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee ADD CONSTRAINT FK_ROSPF_UPDATED_BY FOREIGN KEY (updated_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_STAGE');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_PURPOSE_FEE');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_CREATED_BY');
$this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_UPDATED_BY');
$this->addSql('DROP TABLE road_occupation_stage_purpose_fee');
}
}