migrations/Version20250807160356.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20250807160356 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE estimated_packings (id INT AUTO_INCREMENT NOT NULL, shipment_id INT NOT NULL, createdAt DATETIME NOT NULL, createdBy VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_F1B166C67BE036FC (shipment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE estimated_packing_customer_order_lines (estimatedpacking_id INT NOT NULL, customerorderline_id INT NOT NULL, INDEX IDX_282F6D2686B9A738 (estimatedpacking_id), INDEX IDX_282F6D262A311BE2 (customerorderline_id), PRIMARY KEY(estimatedpacking_id, customerorderline_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE estimated_packings ADD CONSTRAINT FK_F1B166C67BE036FC FOREIGN KEY (shipment_id) REFERENCES shipments (id)');
  21.         $this->addSql('ALTER TABLE estimated_packing_customer_order_lines ADD CONSTRAINT FK_282F6D2686B9A738 FOREIGN KEY (estimatedpacking_id) REFERENCES estimated_packings (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE estimated_packing_customer_order_lines ADD CONSTRAINT FK_282F6D262A311BE2 FOREIGN KEY (customerorderline_id) REFERENCES customer_order_lines (id) ON DELETE CASCADE');
  23.         $this->addSql('ALTER TABLE packings ADD estimatedPacking_id INT DEFAULT NULL, CHANGE shipment_id shipment_id INT DEFAULT NULL');
  24.         $this->addSql('ALTER TABLE packings ADD CONSTRAINT FK_63E6B145C9E4A4E8 FOREIGN KEY (estimatedPacking_id) REFERENCES estimated_packings (id)');
  25.         $this->addSql('CREATE INDEX IDX_63E6B145C9E4A4E8 ON packings (estimatedPacking_id)');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE packings DROP FOREIGN KEY FK_63E6B145C9E4A4E8');
  31.         $this->addSql('ALTER TABLE estimated_packings DROP FOREIGN KEY FK_F1B166C67BE036FC');
  32.         $this->addSql('ALTER TABLE estimated_packing_customer_order_lines DROP FOREIGN KEY FK_282F6D2686B9A738');
  33.         $this->addSql('ALTER TABLE estimated_packing_customer_order_lines DROP FOREIGN KEY FK_282F6D262A311BE2');
  34.         $this->addSql('DROP TABLE estimated_packings');
  35.         $this->addSql('DROP TABLE estimated_packing_customer_order_lines');
  36.         $this->addSql('DROP INDEX IDX_63E6B145C9E4A4E8 ON packings');
  37.         $this->addSql('ALTER TABLE packings DROP estimatedPacking_id, CHANGE shipment_id shipment_id INT NOT NULL');
  38.     }
  39. }