vendor/bluue/manufacturing-bundle/migrations/Version20221208143855.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace ManufacturingBundleMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. use Symfony\Component\Uid\UuidV6;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  */
  10. final class Version20221208143855 extends AbstractMigration
  11. {
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql('CREATE TABLE manufacturing_bundle__product_options (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', product_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', disabled TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_6DC38EA14584665A (product_id), INDEX IDX_6DC38EA1B03A8386 (created_by_id), INDEX IDX_6DC38EA1896DBBDE (updated_by_id), INDEX IDX_6DC38EA1C76F1F52 (deleted_by_id), INDEX disabled (disabled), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options ADD CONSTRAINT FK_6DC38EA14584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
  16.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options ADD CONSTRAINT FK_6DC38EA1B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  17.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options ADD CONSTRAINT FK_6DC38EA1896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  18.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options ADD CONSTRAINT FK_6DC38EA1C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options DROP FOREIGN KEY FK_6DC38EA14584665A');
  23.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options DROP FOREIGN KEY FK_6DC38EA1B03A8386');
  24.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options DROP FOREIGN KEY FK_6DC38EA1896DBBDE');
  25.         $this->addSql('ALTER TABLE manufacturing_bundle__product_options DROP FOREIGN KEY FK_6DC38EA1C76F1F52');
  26.         $this->addSql('DROP TABLE manufacturing_bundle__product_options');
  27.     }
  28.     public function postUp(Schema $schema): void
  29.     {
  30.         parent::postUp($schema);
  31.         $now = (new \DateTime())->format('Y-m-d H:i:s');
  32.         $configuration $this->connection
  33.             ->executeQuery('SELECT value FROM configuration WHERE context_id IS NULL AND name = \'stocks_bundle__default_stock_movement_reason__removal\'')
  34.             ->fetchOne();
  35.         if ($configuration) {
  36.             $this->connection->insert('configuration', [
  37.                 'id' => (new UuidV6())->toBinary(),
  38.                 'name' => 'manufacturing_bundle__transformation_stock_reason',
  39.                 'context_id' => null,
  40.                 'value' => $configuration,
  41.                 'created_at' => $now,
  42.                 'updated_at' => $now
  43.             ]);
  44.         }
  45.     }
  46. }