addSql('ALTER TABLE weight ALTER COLUMN reception_id DROP NOT NULL'); $this->addSql('ALTER TABLE weight ADD shipment_id INT DEFAULT NULL'); $this->addSql('ALTER TABLE weight ADD CONSTRAINT FK_WEIGHT_SHIPMENT FOREIGN KEY (shipment_id) REFERENCES shipment (id) NOT DEFERRABLE'); $this->addSql('CREATE INDEX IDX_WEIGHT_SHIPMENT ON weight (shipment_id)'); $this->addSql('CREATE UNIQUE INDEX uniq_weight_reception_type ON weight (reception_id, type)'); $this->addSql('CREATE UNIQUE INDEX uniq_weight_shipment_type ON weight (shipment_id, type)'); $this->addSql('ALTER TABLE weight ADD CONSTRAINT chk_weight_reception_or_shipment CHECK ((reception_id IS NOT NULL AND shipment_id IS NULL) OR (reception_id IS NULL AND shipment_id IS NOT NULL))'); } public function down(Schema $schema): void { $this->addSql('ALTER TABLE weight DROP CONSTRAINT chk_weight_reception_or_shipment'); $this->addSql('DROP INDEX uniq_weight_shipment_type'); $this->addSql('DROP INDEX uniq_weight_reception_type'); $this->addSql('DROP INDEX IDX_WEIGHT_SHIPMENT'); $this->addSql('ALTER TABLE weight DROP CONSTRAINT FK_WEIGHT_SHIPMENT'); $this->addSql('ALTER TABLE weight DROP shipment_id'); $this->addSql('ALTER TABLE weight ALTER COLUMN reception_id SET NOT NULL'); } }