<?php
declare(strict_types=1);
namespace StocksBundleMigrations;
use App\Services\ObjectSerialize;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\Uid\UuidV6;
final class Version20221208133254 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$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');
$this->addSql('ALTER TABLE stocks_bundle__date_type ADD CONSTRAINT FK_8D4E1F62B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__date_type ADD CONSTRAINT FK_8D4E1F62896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__date_type ADD CONSTRAINT FK_8D4E1F62C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$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');
$this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FF5080ECDE FOREIGN KEY (warehouse_id) REFERENCES stocks_bundle__warehouse (id)');
$this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FFB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FF896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__location ADD CONSTRAINT FK_A4AB83FFC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF34584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF3B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF3896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration ADD CONSTRAINT FK_CAB2DF3C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E0664D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06E3B45410 FOREIGN KEY (sub_location_id) REFERENCES stocks_bundle__sub_location (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06FCAB8B6E FOREIGN KEY (date_type_id) REFERENCES stocks_bundle__date_type (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06EBCD91F6 FOREIGN KEY (stock_product_id) REFERENCES stocks_bundle__stock_product (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_location ADD CONSTRAINT FK_BBA57E06C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$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)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AA145ECC8 FOREIGN KEY (stock_quantity_id) REFERENCES stocks_bundle__stock_quantity (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623A64D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AE3B45410 FOREIGN KEY (sub_location_id) REFERENCES stocks_bundle__sub_location (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623A896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement ADD CONSTRAINT FK_11E6623AC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason ADD CONSTRAINT FK_C4953947B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason ADD CONSTRAINT FK_C4953947896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason ADD CONSTRAINT FK_C4953947C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$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');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line ADD CONSTRAINT FK_C168A566EBCD91F6 FOREIGN KEY (stock_product_id) REFERENCES stocks_bundle__stock_product (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line ADD CONSTRAINT FK_C168A566B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line ADD CONSTRAINT FK_C168A566896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$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)');
$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)');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location ADD CONSTRAINT FK_DF6712FEB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location ADD CONSTRAINT FK_DF6712FE896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C4604584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C4609941A932 FOREIGN KEY (declination_id) REFERENCES products_bundle__declination (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C4605080ECDE FOREIGN KEY (warehouse_id) REFERENCES stocks_bundle__warehouse (id)');
$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)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C460B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C460896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product ADD CONSTRAINT FK_3D03C460C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BB4584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BB9941A932 FOREIGN KEY (declination_id) REFERENCES products_bundle__declination (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BBB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BB896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root ADD CONSTRAINT FK_436271BBC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FBD98387BA FOREIGN KEY (stock_location_id) REFERENCES stocks_bundle__stock_location (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FB38248176 FOREIGN KEY (currency_id) REFERENCES currency (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FBB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FB896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity ADD CONSTRAINT FK_7AC8E1FBC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B6540664D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
$this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B65406B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B65406896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__sub_location ADD CONSTRAINT FK_69B65406C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__warehouse ADD CONSTRAINT FK_CDFD4A43B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__warehouse ADD CONSTRAINT FK_CDFD4A43896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE stocks_bundle__warehouse ADD CONSTRAINT FK_CDFD4A43C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE stocks_bundle__date_type DROP FOREIGN KEY FK_8D4E1F62B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__date_type DROP FOREIGN KEY FK_8D4E1F62896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__date_type DROP FOREIGN KEY FK_8D4E1F62C76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__date_type_translations DROP FOREIGN KEY FK_1B0A15EE232D562B');
$this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FF5080ECDE');
$this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FFB03A8386');
$this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FF896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__location DROP FOREIGN KEY FK_A4AB83FFC76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF34584665A');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF3B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF3896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__product_configuration DROP FOREIGN KEY FK_CAB2DF3C76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E0664D218E');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06E3B45410');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06FCAB8B6E');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06EBCD91F6');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_location DROP FOREIGN KEY FK_BBA57E06C76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AD0E7D5DE');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AA145ECC8');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623A64D218E');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AE3B45410');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AB03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623A896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement DROP FOREIGN KEY FK_11E6623AC76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason DROP FOREIGN KEY FK_C4953947B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason DROP FOREIGN KEY FK_C4953947896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason DROP FOREIGN KEY FK_C4953947C76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__stock_movement_reason_translations DROP FOREIGN KEY FK_C86D085232D562B');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566EBCD91F6');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566BB01DC09');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line DROP FOREIGN KEY FK_C168A566896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FE3F9EF6ED');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FED98387BA');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FEB03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_order_line_location DROP FOREIGN KEY FK_DF6712FE896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C4604584665A');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C4609941A932');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C4605080ECDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C46049760897');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C460B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C460896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_product DROP FOREIGN KEY FK_3D03C460C76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BB4584665A');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BB9941A932');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BBB03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BB896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_product_root DROP FOREIGN KEY FK_436271BBC76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FBD98387BA');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FB38248176');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FBB03A8386');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FB896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__stock_quantity DROP FOREIGN KEY FK_7AC8E1FBC76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B6540664D218E');
$this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B65406B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B65406896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__sub_location DROP FOREIGN KEY FK_69B65406C76F1F52');
$this->addSql('ALTER TABLE stocks_bundle__warehouse DROP FOREIGN KEY FK_CDFD4A43B03A8386');
$this->addSql('ALTER TABLE stocks_bundle__warehouse DROP FOREIGN KEY FK_CDFD4A43896DBBDE');
$this->addSql('ALTER TABLE stocks_bundle__warehouse DROP FOREIGN KEY FK_CDFD4A43C76F1F52');
$this->addSql('DROP TABLE stocks_bundle__date_type');
$this->addSql('DROP TABLE stocks_bundle__date_type_translations');
$this->addSql('DROP TABLE stocks_bundle__location');
$this->addSql('DROP TABLE stocks_bundle__product_configuration');
$this->addSql('DROP TABLE stocks_bundle__stock_location');
$this->addSql('DROP TABLE stocks_bundle__stock_movement');
$this->addSql('DROP TABLE stocks_bundle__stock_movement_reason');
$this->addSql('DROP TABLE stocks_bundle__stock_movement_reason_translations');
$this->addSql('DROP TABLE stocks_bundle__stock_order_line');
$this->addSql('DROP TABLE stocks_bundle__stock_order_line_location');
$this->addSql('DROP TABLE stocks_bundle__stock_product');
$this->addSql('DROP TABLE stocks_bundle__stock_product_root');
$this->addSql('DROP TABLE stocks_bundle__stock_quantity');
$this->addSql('DROP TABLE stocks_bundle__sub_location');
$this->addSql('DROP TABLE stocks_bundle__warehouse');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$now = (new \DateTime())->format('Y-m-d H:i:s');
$configurations = [
'stocks_bundle__creation_auto_stock_product_root_with_new_product_or_declination' => true,
'stocks_bundle__auto_remove_stock_quantity_zero' => false
];
foreach ($configurations as $configuration => $value) {
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => $configuration,
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $value]),
'created_at' => $now,
'updated_at' => $now
]);
}
$languages = $this->connection->executeQuery('SELECT * FROM language WHERE deleted_at IS NULL')
->fetchAllAssociative();
$rootLocale = 'en';
$defaultLocale = $this->connection
->executeQuery('SELECT locale FROM language WHERE deleted_at IS NULL AND is_default = 1')
->fetchOne() ?: 'en';
$dateTypes = [
[
'name_fr' => 'DLUO',
'name_en' => 'Best before',
'long_name_fr' => 'Date limite d\'utilisation optimale',
'long_name_en' => ''
],
[
'name_fr' => 'DLC',
'name_en' => 'Use-by date',
'long_name_fr' => 'Date limite de consommation',
'long_name_en' => ''
]
];
foreach ($dateTypes as $dateType) {
$dateTypeId = (new UuidV6())->toBinary();
$this->connection->insert('stocks_bundle__date_type', [
'id' => $dateTypeId,
'name' => !empty($dateType['name_' . $defaultLocale]) ?
$dateType['name_' . $defaultLocale] : $dateType['name_' . $rootLocale],
'long_name' => !empty($dateType['long_name_' . $defaultLocale]) ?
$dateType['long_name_' . $defaultLocale] : $dateType['long_name_' . $rootLocale],
'created_at' => $now,
'updated_at' => $now
]);
foreach ($languages as $language) {
$localeTo = $rootLocale;
if (!empty($dateType['name_' . $language['locale']])) {
$localeTo = $language['locale'];
} elseif (!empty($dateType['name_' . $defaultLocale])) {
$localeTo = $defaultLocale;
}
$this->connection->insert('stocks_bundle__date_type_translations', [
'object_id' => $dateTypeId,
'locale' => $language['locale'],
'field' => 'name',
'content' => $dateType['name_' . $localeTo]
]);
$this->connection->insert('stocks_bundle__date_type_translations', [
'object_id' => $dateTypeId,
'locale' => $language['locale'],
'field' => 'long_name',
'content' => $dateType['long_name_' . $localeTo]
]);
}
}
$reasons = [
[
'fr' => 'Ajustement de l\'inventaire',
'en' => 'Inventory adjustment'
],
[
'fr' => 'Ajout de stock',
'en' => 'Adding stock',
'configuration' => 'stocks_bundle__default_stock_movement_reason__entry'
],
[
'fr' => 'Retrait du stock',
'en' => 'Withdrawal from stock',
'configuration' => 'stocks_bundle__default_stock_movement_reason__removal'
],
[
'fr' => 'Bon de livraison validé',
'en' => 'Delivery note validate',
'configuration' => 'stocks_bundle__default_stock_movement_reason__delivery_note_validate'
],
[
'fr' => 'Bon de livraison annulé',
'en' => 'Delivery note cancel',
'configuration' => 'stocks_bundle__default_stock_movement_reason__delivery_note_cancel'
],
[
'fr' => 'Suppression du stock',
'en' => 'Delete stock',
'configuration' => 'stocks_bundle__default_stock_movement_reason__delete'
],
[
'fr' => 'Transfert de stock',
'en' => 'Stock transfer',
'configuration' => [
'stocks_bundle__default_stock_movement_reason__transfer',
'stocks_bundle__default_stock_movement_reason__transfer_entry'
]
]
];
foreach ($reasons as $reason) {
$reasonId = new UuidV6();
$this->connection->insert('stocks_bundle__stock_movement_reason', [
'id' => $reasonId->toBinary(),
'name' => !empty($reason[$defaultLocale]) ?
$reason[$defaultLocale] : $reason[$rootLocale],
'created_at' => $now,
'updated_at' => $now
]);
foreach ($languages as $language) {
$localeTo = $rootLocale;
if (!empty($reason[$language['locale']])) {
$localeTo = $language['locale'];
} elseif (!empty($reason[$defaultLocale])) {
$localeTo = $defaultLocale;
}
$this->connection->insert('stocks_bundle__stock_movement_reason_translations', [
'object_id' => $reasonId->toBinary(),
'locale' => $language['locale'],
'field' => 'name',
'content' => $reason[$localeTo]
]);
}
if (!empty($reason['configuration'])) {
if (is_array($reason['configuration'])) {
foreach ($reason['configuration'] as $config) {
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => $config,
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $reasonId]),
'created_at' => $now,
'updated_at' => $now
]);
}
} else {
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => $reason['configuration'],
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $reasonId]),
'created_at' => $now,
'updated_at' => $now
]);
}
}
}
}
}