<?php
declare(strict_types=1);
namespace InventoriesBundleMigrations;
use App\Services\ObjectSerialize;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\Uid\UuidV6;
final class Version20221208150955 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE inventories_bundle__inventory (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', warehouse_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', location_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', sub_location_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', brand_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)\', validated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', category_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', supplier_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', reference VARCHAR(128) DEFAULT NULL, name VARCHAR(128) NOT NULL, x VARCHAR(128) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, validated_at DATETIME DEFAULT NULL, INDEX IDX_F5586DDC5080ECDE (warehouse_id), INDEX IDX_F5586DDC64D218E (location_id), INDEX IDX_F5586DDCE3B45410 (sub_location_id), INDEX IDX_F5586DDC44F5D008 (brand_id), INDEX IDX_F5586DDCB03A8386 (created_by_id), INDEX IDX_F5586DDC896DBBDE (updated_by_id), INDEX IDX_F5586DDCC76F1F52 (deleted_by_id), INDEX IDX_F5586DDCC69DE5E5 (validated_by_id), INDEX IDX_F5586DDC12469DE2 (category_id), INDEX IDX_F5586DDC2ADD6D8C (supplier_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE inventories_bundle__inventory_original_product (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', inventory_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', product_id BINARY(16) DEFAULT 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)\', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_52C557F9EEA759 (inventory_id), INDEX IDX_52C557F4584665A (product_id), INDEX IDX_52C557F9941A932 (declination_id), INDEX IDX_52C557FB03A8386 (created_by_id), INDEX IDX_52C557F896DBBDE (updated_by_id), INDEX IDX_52C557FC76F1F52 (deleted_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE inventories_bundle__inventory_product (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', inventory_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', product_id BINARY(16) DEFAULT 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)\', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_7CD8FE119EEA759 (inventory_id), INDEX IDX_7CD8FE114584665A (product_id), INDEX IDX_7CD8FE119941A932 (declination_id), INDEX IDX_7CD8FE11B03A8386 (created_by_id), INDEX IDX_7CD8FE11896DBBDE (updated_by_id), INDEX IDX_7CD8FE11C76F1F52 (deleted_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE inventories_bundle__inventory_product_quantity (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', inventory_product_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', stock_location_id BINARY(16) DEFAULT 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)\', 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, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_4A5838466A33D9 (inventory_product_id), INDEX IDX_4A58384D98387BA (stock_location_id), INDEX IDX_4A5838464D218E (location_id), INDEX IDX_4A58384E3B45410 (sub_location_id), INDEX IDX_4A58384FCAB8B6E (date_type_id), INDEX IDX_4A58384B03A8386 (created_by_id), INDEX IDX_4A58384896DBBDE (updated_by_id), INDEX IDX_4A58384C76F1F52 (deleted_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDC5080ECDE FOREIGN KEY (warehouse_id) REFERENCES stocks_bundle__warehouse (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDC64D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDCE3B45410 FOREIGN KEY (sub_location_id) REFERENCES stocks_bundle__sub_location (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDC44F5D008 FOREIGN KEY (brand_id) REFERENCES products_bundle__brand (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDCB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDC896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDCC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory ADD CONSTRAINT FK_F5586DDCC69DE5E5 FOREIGN KEY (validated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product ADD CONSTRAINT FK_52C557F9EEA759 FOREIGN KEY (inventory_id) REFERENCES inventories_bundle__inventory (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product ADD CONSTRAINT FK_52C557F4584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product ADD CONSTRAINT FK_52C557F9941A932 FOREIGN KEY (declination_id) REFERENCES products_bundle__declination (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product ADD CONSTRAINT FK_52C557FB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product ADD CONSTRAINT FK_52C557F896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product ADD CONSTRAINT FK_52C557FC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product ADD CONSTRAINT FK_7CD8FE119EEA759 FOREIGN KEY (inventory_id) REFERENCES inventories_bundle__inventory (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product ADD CONSTRAINT FK_7CD8FE114584665A FOREIGN KEY (product_id) REFERENCES products_bundle__product (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product ADD CONSTRAINT FK_7CD8FE119941A932 FOREIGN KEY (declination_id) REFERENCES products_bundle__declination (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product ADD CONSTRAINT FK_7CD8FE11B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product ADD CONSTRAINT FK_7CD8FE11896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product ADD CONSTRAINT FK_7CD8FE11C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A5838466A33D9 FOREIGN KEY (inventory_product_id) REFERENCES inventories_bundle__inventory_product (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A58384D98387BA FOREIGN KEY (stock_location_id) REFERENCES stocks_bundle__stock_location (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A5838464D218E FOREIGN KEY (location_id) REFERENCES stocks_bundle__location (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A58384E3B45410 FOREIGN KEY (sub_location_id) REFERENCES stocks_bundle__sub_location (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A58384FCAB8B6E FOREIGN KEY (date_type_id) REFERENCES stocks_bundle__date_type (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A58384B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A58384896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity ADD CONSTRAINT FK_4A58384C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDC5080ECDE');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDC64D218E');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDCE3B45410');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDC44F5D008');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDCB03A8386');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDC896DBBDE');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDCC76F1F52');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDCC69DE5E5');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDC12469DE2');
$this->addSql('ALTER TABLE inventories_bundle__inventory DROP FOREIGN KEY FK_F5586DDC2ADD6D8C');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product DROP FOREIGN KEY FK_52C557F9EEA759');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product DROP FOREIGN KEY FK_52C557F4584665A');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product DROP FOREIGN KEY FK_52C557F9941A932');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product DROP FOREIGN KEY FK_52C557FB03A8386');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product DROP FOREIGN KEY FK_52C557F896DBBDE');
$this->addSql('ALTER TABLE inventories_bundle__inventory_original_product DROP FOREIGN KEY FK_52C557FC76F1F52');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product DROP FOREIGN KEY FK_7CD8FE119EEA759');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product DROP FOREIGN KEY FK_7CD8FE114584665A');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product DROP FOREIGN KEY FK_7CD8FE119941A932');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product DROP FOREIGN KEY FK_7CD8FE11B03A8386');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product DROP FOREIGN KEY FK_7CD8FE11896DBBDE');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product DROP FOREIGN KEY FK_7CD8FE11C76F1F52');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A5838466A33D9');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A58384D98387BA');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A5838464D218E');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A58384E3B45410');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A58384FCAB8B6E');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A58384B03A8386');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A58384896DBBDE');
$this->addSql('ALTER TABLE inventories_bundle__inventory_product_quantity DROP FOREIGN KEY FK_4A58384C76F1F52');
$this->addSql('DROP TABLE inventories_bundle__inventory');
$this->addSql('DROP TABLE inventories_bundle__inventory_original_product');
$this->addSql('DROP TABLE inventories_bundle__inventory_product');
$this->addSql('DROP TABLE inventories_bundle__inventory_product_quantity');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$now = (new \DateTime())->format('Y-m-d H:i:s');
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => 'inventories_bundle__inventory_format',
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => 'INV/[[number]]']),
'created_at' => $now,
'updated_at' => $now
]);
}
}