migrations/Version20260807160000.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20260807160000 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Add road_occupation_stage_purpose_fee for dynamic occupation purpose fees per stage (#29749).';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('CREATE TABLE road_occupation_stage_purpose_fee (
  15.             id UUID NOT NULL,
  16.             stage_id UUID NOT NULL,
  17.             purpose_fee_id UUID NOT NULL,
  18.             width DOUBLE PRECISION DEFAULT NULL,
  19.             length DOUBLE PRECISION DEFAULT NULL,
  20.             area DOUBLE PRECISION DEFAULT NULL,
  21.             ordinal_number INT DEFAULT NULL,
  22.             created_by UUID DEFAULT NULL,
  23.             updated_by UUID DEFAULT NULL,
  24.             created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
  25.             updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
  26.             deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
  27.             PRIMARY KEY(id)
  28.         )');
  29.         $this->addSql('CREATE INDEX IDX_ROSPF_STAGE ON road_occupation_stage_purpose_fee (stage_id)');
  30.         $this->addSql('CREATE INDEX IDX_ROSPF_PURPOSE_FEE ON road_occupation_stage_purpose_fee (purpose_fee_id)');
  31.         $this->addSql('CREATE INDEX IDX_ROSPF_CREATED_BY ON road_occupation_stage_purpose_fee (created_by)');
  32.         $this->addSql('CREATE INDEX IDX_ROSPF_UPDATED_BY ON road_occupation_stage_purpose_fee (updated_by)');
  33.         $this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.id IS \'(DC2Type:uuid)\'');
  34.         $this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.stage_id IS \'(DC2Type:uuid)\'');
  35.         $this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.purpose_fee_id IS \'(DC2Type:uuid)\'');
  36.         $this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.created_by IS \'(DC2Type:uuid)\'');
  37.         $this->addSql('COMMENT ON COLUMN road_occupation_stage_purpose_fee.updated_by IS \'(DC2Type:uuid)\'');
  38.         $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');
  39.         $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');
  40.         $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');
  41.         $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');
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.         $this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_STAGE');
  46.         $this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_PURPOSE_FEE');
  47.         $this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_CREATED_BY');
  48.         $this->addSql('ALTER TABLE road_occupation_stage_purpose_fee DROP CONSTRAINT FK_ROSPF_UPDATED_BY');
  49.         $this->addSql('DROP TABLE road_occupation_stage_purpose_fee');
  50.     }
  51. }