vendor/bluue/stocks-bundle/migrations/Version20221208133254.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace StocksBundleMigrations;
  4. use App\Services\ObjectSerialize;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. use Symfony\Component\Uid\UuidV6;
  8. final class Version20221208133254 extends AbstractMigration
  9. {
  10.     private ObjectSerialize $objectSerialize;
  11.     public function setObjectSerialize(ObjectSerialize $objectSerialize)
  12.     {
  13.         $this->objectSerialize $objectSerialize;
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('CREATE TABLE stocks_bundle__date_type (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)\', name VARCHAR(50) NOT NULL, long_name VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_8D4E1F62B03A8386 (created_by_id), INDEX IDX_8D4E1F62896DBBDE (updated_by_id), INDEX IDX_8D4E1F62C76F1F52 (deleted_by_id), INDEX name (name), INDEX long_name (long_name), 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');
  18.         $this->addSql('CREATE TABLE stocks_bundle__date_type_translations (id INT AUTO_INCREMENT NOT NULL, object_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_1B0A15EE232D562B (object_id), FULLTEXT INDEX content (content), UNIQUE INDEX lookup_unique_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE stocks_bundle__location (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', warehouse_id BINARY(16) DEFAULT 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)\', x VARCHAR(20) NOT NULL COMMENT \'Aisle\', y VARCHAR(20) NOT NULL COMMENT \'Cross-Aisle\', z VARCHAR(20) NOT NULL COMMENT \'Stage\', width INT NOT NULL, is_default_for_empty_sub_location TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_A4AB83FF5080ECDE (warehouse_id), INDEX IDX_A4AB83FFB03A8386 (created_by_id), INDEX IDX_A4AB83FF896DBBDE (updated_by_id), INDEX IDX_A4AB83FFC76F1F52 (deleted_by_id), INDEX x (x), INDEX y (y), INDEX z (z), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), UNIQUE INDEX location_unique (warehouse_id, x, y, z, deleted_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE stocks_bundle__product_configuration (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', product_id BINARY(16) DEFAULT 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)\', unique_stock_picker TINYINT(1) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_CAB2DF34584665A (product_id), INDEX IDX_CAB2DF3B03A8386 (created_by_id), INDEX IDX_CAB2DF3896DBBDE (updated_by_id), INDEX IDX_CAB2DF3C76F1F52 (deleted_by_id), 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');
  21.         $this->addSql('CREATE TABLE stocks_bundle__stock_location (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', location_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', sub_location_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', date_type_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', stock_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)\', date DATETIME DEFAULT NULL, batch_number VARCHAR(255) DEFAULT NULL, quantity INT NOT NULL, quantity_in_order INT NOT NULL, quantity_simulated INT NOT NULL, quantity_available INT NOT NULL, note LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_BBA57E0664D218E (location_id), INDEX IDX_BBA57E06E3B45410 (sub_location_id), INDEX IDX_BBA57E06FCAB8B6E (date_type_id), INDEX IDX_BBA57E06EBCD91F6 (stock_product_id), INDEX IDX_BBA57E06B03A8386 (created_by_id), INDEX IDX_BBA57E06896DBBDE (updated_by_id), INDEX IDX_BBA57E06C76F1F52 (deleted_by_id), INDEX batch_number (batch_number), INDEX quantity (quantity), INDEX quantity_in_order (quantity_in_order), INDEX quantity_simulated (quantity_simulated), INDEX date (date), 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');
  22.         $this->addSql('CREATE TABLE stocks_bundle__stock_movement (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_movement_reason_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', stock_quantity_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', location_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', sub_location_id BINARY(16) DEFAULT 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)\', quantity INT NOT NULL, sign INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_11E6623AD0E7D5DE (stock_movement_reason_id), INDEX IDX_11E6623AA145ECC8 (stock_quantity_id), INDEX IDX_11E6623A64D218E (location_id), INDEX IDX_11E6623AE3B45410 (sub_location_id), INDEX IDX_11E6623AB03A8386 (created_by_id), INDEX IDX_11E6623A896DBBDE (updated_by_id), INDEX IDX_11E6623AC76F1F52 (deleted_by_id), INDEX quantity (quantity), INDEX sign (sign), 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');
  23.         $this->addSql('CREATE TABLE stocks_bundle__stock_movement_reason (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)\', name VARCHAR(50) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_C4953947B03A8386 (created_by_id), INDEX IDX_C4953947896DBBDE (updated_by_id), INDEX IDX_C4953947C76F1F52 (deleted_by_id), INDEX name (name), 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');
  24.         $this->addSql('CREATE TABLE stocks_bundle__stock_movement_reason_translations (id INT AUTO_INCREMENT NOT NULL, object_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_C86D085232D562B (object_id), FULLTEXT INDEX content (content), UNIQUE INDEX lookup_unique_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  25.         $this->addSql('CREATE TABLE stocks_bundle__stock_order_line (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_product_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', order_line_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', quantity INT NOT NULL, quantity_available INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_C168A566EBCD91F6 (stock_product_id), UNIQUE INDEX UNIQ_C168A566BB01DC09 (order_line_id), INDEX IDX_C168A566B03A8386 (created_by_id), INDEX IDX_C168A566896DBBDE (updated_by_id), INDEX quantity (quantity), INDEX quantity_available (quantity_available), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  26.         $this->addSql('CREATE TABLE stocks_bundle__stock_order_line_location (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_order_line_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_location_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)\', quantity INT NOT NULL, quantity_available INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_DF6712FE3F9EF6ED (stock_order_line_id), INDEX IDX_DF6712FED98387BA (stock_location_id), INDEX IDX_DF6712FEB03A8386 (created_by_id), INDEX IDX_DF6712FE896DBBDE (updated_by_id), INDEX quantity (quantity), INDEX quantity_available (quantity_available), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  27.         $this->addSql('CREATE TABLE stocks_bundle__stock_product (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', product_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', declination_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', warehouse_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_product_root_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)\', quantity INT NOT NULL, quantity_in_order INT NOT NULL, quantity_simulated INT NOT NULL, quantity_available INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_3D03C4604584665A (product_id), INDEX IDX_3D03C4609941A932 (declination_id), INDEX IDX_3D03C4605080ECDE (warehouse_id), INDEX IDX_3D03C46049760897 (stock_product_root_id), INDEX IDX_3D03C460B03A8386 (created_by_id), INDEX IDX_3D03C460896DBBDE (updated_by_id), INDEX IDX_3D03C460C76F1F52 (deleted_by_id), INDEX quantity (quantity), INDEX quantity_in_order (quantity_in_order), INDEX quantity_simulated (quantity_simulated), 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');
  28.         $this->addSql('CREATE TABLE stocks_bundle__stock_product_root (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', product_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', declination_id BINARY(16) DEFAULT 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)\', quantity INT NOT NULL, quantity_in_order INT NOT NULL, quantity_simulated INT NOT NULL, quantity_available INT NOT NULL, quantity_to_hold INT DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_436271BB4584665A (product_id), UNIQUE INDEX UNIQ_436271BB9941A932 (declination_id), INDEX IDX_436271BBB03A8386 (created_by_id), INDEX IDX_436271BB896DBBDE (updated_by_id), INDEX IDX_436271BBC76F1F52 (deleted_by_id), INDEX quantity (quantity), INDEX quantity_in_order (quantity_in_order), INDEX quantity_simulated (quantity_simulated), INDEX quantity_to_hold (quantity_to_hold), 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');
  29.         $this->addSql('CREATE TABLE stocks_bundle__stock_quantity (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_location_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', currency_id BINARY(16) DEFAULT 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)\', quantity INT NOT NULL, date_entry DATETIME NOT NULL, quantity_entry INT NOT NULL, wholesale_price NUMERIC(20, 6) DEFAULT NULL, currency_change_rate NUMERIC(20, 12) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_7AC8E1FBD98387BA (stock_location_id), INDEX IDX_7AC8E1FB38248176 (currency_id), INDEX IDX_7AC8E1FBB03A8386 (created_by_id), INDEX IDX_7AC8E1FB896DBBDE (updated_by_id), INDEX IDX_7AC8E1FBC76F1F52 (deleted_by_id), INDEX quantity (quantity), INDEX quantity_entry (quantity_entry), INDEX wholesale_price (wholesale_price), INDEX currency_change_rate (currency_change_rate), INDEX date_entry (date_entry), 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');
  30.         $this->addSql('CREATE TABLE stocks_bundle__sub_location (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', location_id BINARY(16) DEFAULT 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)\', reference VARCHAR(20) NOT NULL, width INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_69B6540664D218E (location_id), INDEX IDX_69B65406B03A8386 (created_by_id), INDEX IDX_69B65406896DBBDE (updated_by_id), INDEX IDX_69B65406C76F1F52 (deleted_by_id), INDEX reference (reference), 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');
  31.         $this->addSql('CREATE TABLE stocks_bundle__warehouse (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)\', name VARCHAR(50) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_CDFD4A43B03A8386 (created_by_id), INDEX IDX_CDFD4A43896DBBDE (updated_by_id), INDEX IDX_CDFD4A43C76F1F52 (deleted_by_id), INDEX name (name), 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');
  32.         $this->addSql('ALTER TABLE stocks_bundle__date_type ADD CONSTRAINT FK_8D4E1F62B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  33.         $this->addSql('ALTER TABLE stocks_bundle__date_type ADD CONSTRAINT FK_8D4E1F62896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  34.         $this->addSql('ALTER TABLE stocks_bundle__date_type ADD CONSTRAINT FK_8D4E1F62C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  35.         $this->addSql('ALTER TABLE stocks_bundle__date_type_translations ADD CONSTRAINT FK_1B0A15EE232D562B FOREIGN KEY (object_id) REFERENCES stocks_bundle__date_type (id) ON DELETE CASCADE');
  36.         $this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FF5080ECDE FOREIGN KEY (warehouse_id) REFERENCES stocks_bundle__warehouse (id)');
  37.         $this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FFB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  38.         $this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FF896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  39.         $this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FFC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  40.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF34584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
  41.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF3B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  42.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF3896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  43.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF3C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  44.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E0664D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
  45.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06E3B45410 FOREIGN KEY (sub_location_id) REFERENCES stocks_bundle__sub_location (id)');
  46.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06FCAB8B6E FOREIGN KEY (date_type_id) REFERENCES stocks_bundle__date_type (id)');
  47.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06EBCD91F6 FOREIGN KEY (stock_product_id) REFERENCES stocks_bundle__stock_product (id)');
  48.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  49.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  50.         $this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  51.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AD0E7D5DE FOREIGN KEY (stock_movement_reason_id) REFERENCES stocks_bundle__stock_movement_reason (id)');
  52.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AA145ECC8 FOREIGN KEY (stock_quantity_id) REFERENCES stocks_bundle__stock_quantity (id)');
  53.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623A64D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
  54.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AE3B45410 FOREIGN KEY (sub_location_id) REFERENCES stocks_bundle__sub_location (id)');
  55.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  56.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623A896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  57.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  58.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason ADD CONSTRAINT FK_C4953947B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  59.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason ADD CONSTRAINT FK_C4953947896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  60.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason ADD CONSTRAINT FK_C4953947C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  61.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason_translations ADD CONSTRAINT FK_C86D085232D562B FOREIGN KEY (object_id) REFERENCES stocks_bundle__stock_movement_reason (id) ON DELETE CASCADE');
  62.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line ADD CONSTRAINT FK_C168A566EBCD91F6 FOREIGN KEY (stock_product_id) REFERENCES stocks_bundle__stock_product (id)');
  63.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line ADD CONSTRAINT FK_C168A566B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  64.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line ADD CONSTRAINT FK_C168A566896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  65.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location ADD CONSTRAINT FK_DF6712FE3F9EF6ED FOREIGN KEY (stock_order_line_id) REFERENCES stocks_bundle__stock_order_line (id)');
  66.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location ADD CONSTRAINT FK_DF6712FED98387BA FOREIGN KEY (stock_location_id) REFERENCES stocks_bundle__stock_location (id)');
  67.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location ADD CONSTRAINT FK_DF6712FEB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  68.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location ADD CONSTRAINT FK_DF6712FE896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  69.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C4604584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
  70.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C4609941A932 FOREIGN KEY (declination_id) REFERENCES products_bundle__declination (id)');
  71.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C4605080ECDE FOREIGN KEY (warehouse_id) REFERENCES stocks_bundle__warehouse (id)');
  72.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C46049760897 FOREIGN KEY (stock_product_root_id) REFERENCES stocks_bundle__stock_product_root (id)');
  73.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C460B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  74.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C460896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  75.         $this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C460C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  76.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BB4584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
  77.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BB9941A932 FOREIGN KEY (declination_id) REFERENCES products_bundle__declination (id)');
  78.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BBB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  79.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BB896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  80.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BBC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  81.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FBD98387BA FOREIGN KEY (stock_location_id) REFERENCES stocks_bundle__stock_location (id)');
  82.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FB38248176 FOREIGN KEY (currency_id) REFERENCES currency (id)');
  83.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FBB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  84.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FB896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  85.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FBC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  86.         $this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B6540664D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
  87.         $this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B65406B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  88.         $this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B65406896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  89.         $this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B65406C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  90.         $this->addSql('ALTER TABLE stocks_bundle__warehouse ADD CONSTRAINT FK_CDFD4A43B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  91.         $this->addSql('ALTER TABLE stocks_bundle__warehouse ADD CONSTRAINT FK_CDFD4A43896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
  92.         $this->addSql('ALTER TABLE stocks_bundle__warehouse ADD CONSTRAINT FK_CDFD4A43C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
  93.     }
  94.     public function down(Schema $schema): void
  95.     {
  96.         $this->addSql('ALTER TABLE stocks_bundle__date_type DROP FOREIGN KEY FK_8D4E1F62B03A8386');
  97.         $this->addSql('ALTER TABLE stocks_bundle__date_type DROP FOREIGN KEY FK_8D4E1F62896DBBDE');
  98.         $this->addSql('ALTER TABLE stocks_bundle__date_type DROP FOREIGN KEY FK_8D4E1F62C76F1F52');
  99.         $this->addSql('ALTER TABLE stocks_bundle__date_type_translations DROP FOREIGN KEY FK_1B0A15EE232D562B');
  100.         $this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FF5080ECDE');
  101.         $this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FFB03A8386');
  102.         $this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FF896DBBDE');
  103.         $this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FFC76F1F52');
  104.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF34584665A');
  105.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF3B03A8386');
  106.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF3896DBBDE');
  107.         $this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF3C76F1F52');
  108.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E0664D218E');
  109.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06E3B45410');
  110.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06FCAB8B6E');
  111.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06EBCD91F6');
  112.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06B03A8386');
  113.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06896DBBDE');
  114.         $this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06C76F1F52');
  115.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AD0E7D5DE');
  116.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AA145ECC8');
  117.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623A64D218E');
  118.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AE3B45410');
  119.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AB03A8386');
  120.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623A896DBBDE');
  121.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AC76F1F52');
  122.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason DROP FOREIGN KEY FK_C4953947B03A8386');
  123.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason DROP FOREIGN KEY FK_C4953947896DBBDE');
  124.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason DROP FOREIGN KEY FK_C4953947C76F1F52');
  125.         $this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason_translations DROP FOREIGN KEY FK_C86D085232D562B');
  126.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566EBCD91F6');
  127.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566BB01DC09');
  128.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566B03A8386');
  129.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566896DBBDE');
  130.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FE3F9EF6ED');
  131.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FED98387BA');
  132.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FEB03A8386');
  133.         $this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FE896DBBDE');
  134.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C4604584665A');
  135.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C4609941A932');
  136.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C4605080ECDE');
  137.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C46049760897');
  138.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C460B03A8386');
  139.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C460896DBBDE');
  140.         $this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C460C76F1F52');
  141.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BB4584665A');
  142.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BB9941A932');
  143.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BBB03A8386');
  144.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BB896DBBDE');
  145.         $this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BBC76F1F52');
  146.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FBD98387BA');
  147.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FB38248176');
  148.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FBB03A8386');
  149.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FB896DBBDE');
  150.         $this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FBC76F1F52');
  151.         $this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B6540664D218E');
  152.         $this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B65406B03A8386');
  153.         $this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B65406896DBBDE');
  154.         $this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B65406C76F1F52');
  155.         $this->addSql('ALTER TABLE stocks_bundle__warehouse DROP FOREIGN KEY FK_CDFD4A43B03A8386');
  156.         $this->addSql('ALTER TABLE stocks_bundle__warehouse DROP FOREIGN KEY FK_CDFD4A43896DBBDE');
  157.         $this->addSql('ALTER TABLE stocks_bundle__warehouse DROP FOREIGN KEY FK_CDFD4A43C76F1F52');
  158.         $this->addSql('DROP TABLE stocks_bundle__date_type');
  159.         $this->addSql('DROP TABLE stocks_bundle__date_type_translations');
  160.         $this->addSql('DROP TABLE stocks_bundle__location');
  161.         $this->addSql('DROP TABLE stocks_bundle__product_configuration');
  162.         $this->addSql('DROP TABLE stocks_bundle__stock_location');
  163.         $this->addSql('DROP TABLE stocks_bundle__stock_movement');
  164.         $this->addSql('DROP TABLE stocks_bundle__stock_movement_reason');
  165.         $this->addSql('DROP TABLE stocks_bundle__stock_movement_reason_translations');
  166.         $this->addSql('DROP TABLE stocks_bundle__stock_order_line');
  167.         $this->addSql('DROP TABLE stocks_bundle__stock_order_line_location');
  168.         $this->addSql('DROP TABLE stocks_bundle__stock_product');
  169.         $this->addSql('DROP TABLE stocks_bundle__stock_product_root');
  170.         $this->addSql('DROP TABLE stocks_bundle__stock_quantity');
  171.         $this->addSql('DROP TABLE stocks_bundle__sub_location');
  172.         $this->addSql('DROP TABLE stocks_bundle__warehouse');
  173.     }
  174.     public function postUp(Schema $schema): void
  175.     {
  176.         parent::postUp($schema);
  177.         $now = (new \DateTime())->format('Y-m-d H:i:s');
  178.         $configurations = [
  179.             'stocks_bundle__creation_auto_stock_product_root_with_new_product_or_declination' => true,
  180.             'stocks_bundle__auto_remove_stock_quantity_zero' => false
  181.         ];
  182.         foreach ($configurations as $configuration => $value) {
  183.             $this->connection->insert('configuration', [
  184.                 'id' => (new UuidV6())->toBinary(),
  185.                 'name' => $configuration,
  186.                 'context_id' => null,
  187.                 'value' => $this->objectSerialize->add((object) ['value' => $value]),
  188.                 'created_at' => $now,
  189.                 'updated_at' => $now
  190.             ]);
  191.         }
  192.         $languages $this->connection->executeQuery('SELECT * FROM language WHERE deleted_at IS NULL')
  193.             ->fetchAllAssociative();
  194.         $rootLocale 'en';
  195.         $defaultLocale $this->connection
  196.             ->executeQuery('SELECT locale FROM language WHERE deleted_at IS NULL AND is_default = 1')
  197.             ->fetchOne() ?: 'en';
  198.         $dateTypes = [
  199.             [
  200.                 'name_fr' => 'DLUO',
  201.                 'name_en' => 'Best before',
  202.                 'long_name_fr' => 'Date limite d\'utilisation optimale',
  203.                 'long_name_en' => ''
  204.             ],
  205.             [
  206.                 'name_fr' => 'DLC',
  207.                 'name_en' => 'Use-by date',
  208.                 'long_name_fr' => 'Date limite de consommation',
  209.                 'long_name_en' => ''
  210.             ]
  211.         ];
  212.         foreach ($dateTypes as $dateType) {
  213.             $dateTypeId = (new UuidV6())->toBinary();
  214.             $this->connection->insert('stocks_bundle__date_type', [
  215.                 'id' => $dateTypeId,
  216.                 'name' => !empty($dateType['name_' $defaultLocale]) ?
  217.                     $dateType['name_' $defaultLocale] : $dateType['name_' $rootLocale],
  218.                 'long_name' => !empty($dateType['long_name_' $defaultLocale]) ?
  219.                     $dateType['long_name_' $defaultLocale] : $dateType['long_name_' $rootLocale],
  220.                 'created_at' => $now,
  221.                 'updated_at' => $now
  222.             ]);
  223.             foreach ($languages as $language) {
  224.                 $localeTo $rootLocale;
  225.                 if (!empty($dateType['name_' $language['locale']])) {
  226.                     $localeTo $language['locale'];
  227.                 } elseif (!empty($dateType['name_' $defaultLocale])) {
  228.                     $localeTo $defaultLocale;
  229.                 }
  230.                 $this->connection->insert('stocks_bundle__date_type_translations', [
  231.                     'object_id' => $dateTypeId,
  232.                     'locale' => $language['locale'],
  233.                     'field' => 'name',
  234.                     'content' => $dateType['name_' $localeTo]
  235.                 ]);
  236.                 $this->connection->insert('stocks_bundle__date_type_translations', [
  237.                     'object_id' => $dateTypeId,
  238.                     'locale' => $language['locale'],
  239.                     'field' => 'long_name',
  240.                     'content' => $dateType['long_name_' $localeTo]
  241.                 ]);
  242.             }
  243.         }
  244.         $reasons = [
  245.             [
  246.                 'fr' => 'Ajustement de l\'inventaire',
  247.                 'en' => 'Inventory adjustment'
  248.             ],
  249.             [
  250.                 'fr' => 'Ajout de stock',
  251.                 'en' => 'Adding stock',
  252.                 'configuration' => 'stocks_bundle__default_stock_movement_reason__entry'
  253.             ],
  254.             [
  255.                 'fr' => 'Retrait du stock',
  256.                 'en' => 'Withdrawal from stock',
  257.                 'configuration' => 'stocks_bundle__default_stock_movement_reason__removal'
  258.             ],
  259.             [
  260.                 'fr' => 'Bon de livraison validĂ©',
  261.                 'en' => 'Delivery note validate',
  262.                 'configuration' => 'stocks_bundle__default_stock_movement_reason__delivery_note_validate'
  263.             ],
  264.             [
  265.                 'fr' => 'Bon de livraison annulĂ©',
  266.                 'en' => 'Delivery note cancel',
  267.                 'configuration' => 'stocks_bundle__default_stock_movement_reason__delivery_note_cancel'
  268.             ],
  269.             [
  270.                 'fr' => 'Suppression du stock',
  271.                 'en' => 'Delete stock',
  272.                 'configuration' => 'stocks_bundle__default_stock_movement_reason__delete'
  273.             ],
  274.             [
  275.                 'fr' => 'Transfert de stock',
  276.                 'en' => 'Stock transfer',
  277.                 'configuration' => [
  278.                     'stocks_bundle__default_stock_movement_reason__transfer',
  279.                     'stocks_bundle__default_stock_movement_reason__transfer_entry'
  280.                 ]
  281.             ]
  282.         ];
  283.         foreach ($reasons as $reason) {
  284.             $reasonId = new UuidV6();
  285.             $this->connection->insert('stocks_bundle__stock_movement_reason', [
  286.                 'id' => $reasonId->toBinary(),
  287.                 'name' => !empty($reason[$defaultLocale]) ?
  288.                     $reason[$defaultLocale] : $reason[$rootLocale],
  289.                 'created_at' => $now,
  290.                 'updated_at' => $now
  291.             ]);
  292.             foreach ($languages as $language) {
  293.                 $localeTo $rootLocale;
  294.                 if (!empty($reason[$language['locale']])) {
  295.                     $localeTo $language['locale'];
  296.                 } elseif (!empty($reason[$defaultLocale])) {
  297.                     $localeTo $defaultLocale;
  298.                 }
  299.                 $this->connection->insert('stocks_bundle__stock_movement_reason_translations', [
  300.                     'object_id' => $reasonId->toBinary(),
  301.                     'locale' => $language['locale'],
  302.                     'field' => 'name',
  303.                     'content' => $reason[$localeTo]
  304.                 ]);
  305.             }
  306.             if (!empty($reason['configuration'])) {
  307.                 if (is_array($reason['configuration'])) {
  308.                     foreach ($reason['configuration'] as $config) {
  309.                         $this->connection->insert('configuration', [
  310.                             'id' => (new UuidV6())->toBinary(),
  311.                             'name' => $config,
  312.                             'context_id' => null,
  313.                             'value' => $this->objectSerialize->add((object) ['value' => $reasonId]),
  314.                             'created_at' => $now,
  315.                             'updated_at' => $now
  316.                         ]);
  317.                     }
  318.                 } else {
  319.                     $this->connection->insert('configuration', [
  320.                         'id' => (new UuidV6())->toBinary(),
  321.                         'name' => $reason['configuration'],
  322.                         'context_id' => null,
  323.                         'value' => $this->objectSerialize->add((object) ['value' => $reasonId]),
  324.                         'created_at' => $now,
  325.                         'updated_at' => $now
  326.                     ]);
  327.                 }
  328.             }
  329.         }
  330.     }
  331. }