<?php
declare(strict_types=1);
namespace CoreMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220429113800 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE customers_bundle__customer_type_translations (id INT AUTO_INCREMENT NOT NULL, object_id INT DEFAULT NULL, locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_AF7CDEC7232D562B (object_id), 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 sales_bundle__additional_pdf (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', file_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)\', for_quotation TINYINT(1) NOT NULL, for_order TINYINT(1) NOT NULL, for_delivery_note TINYINT(1) NOT NULL, for_invoice TINYINT(1) NOT NULL, for_credit_note TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, is_active TINYINT(1) NOT NULL, INDEX IDX_3CDB90D193CB796C (file_id), INDEX IDX_3CDB90D1B03A8386 (created_by_id), INDEX IDX_3CDB90D1896DBBDE (updated_by_id), INDEX IDX_3CDB90D1C76F1F52 (deleted_by_id), INDEX for_quotation (for_quotation), INDEX for_order (for_order), INDEX for_delivery_note (for_delivery_note), INDEX for_invoice (for_invoice), INDEX for_credit_note (for_credit_note), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE sales_bundle__customer_options (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', customer_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)\', for_quotation TINYINT(1) NOT NULL, for_order TINYINT(1) NOT NULL, for_delivery_note TINYINT(1) NOT NULL, for_invoice TINYINT(1) NOT NULL, for_credit_note TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_5E01AC229395C3F3 (customer_id), INDEX IDX_5E01AC22B03A8386 (created_by_id), INDEX IDX_5E01AC22896DBBDE (updated_by_id), INDEX IDX_5E01AC22C76F1F52 (deleted_by_id), INDEX for_quotation (for_quotation), INDEX for_order (for_order), INDEX for_delivery_note (for_delivery_note), INDEX for_invoice (for_invoice), INDEX for_credit_note (for_credit_note), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE suppliers_bundle__supplier_context (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', supplier_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', context_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', INDEX IDX_CF412AA72ADD6D8C (supplier_id), INDEX IDX_CF412AA76B00C1CF (context_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE webservice_key (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)\', api_key VARCHAR(32) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, is_active TINYINT(1) NOT NULL, INDEX IDX_4AEB92AAB03A8386 (created_by_id), INDEX IDX_4AEB92AA896DBBDE (updated_by_id), INDEX IDX_4AEB92AAC76F1F52 (deleted_by_id), INDEX api_key (api_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE webservice_permission (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', webservice_key_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)\', resource VARCHAR(255) NOT NULL, get_method TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_A9BE18AC601CEA4 (webservice_key_id), INDEX IDX_A9BE18AB03A8386 (created_by_id), INDEX IDX_A9BE18A896DBBDE (updated_by_id), INDEX IDX_A9BE18AC76F1F52 (deleted_by_id), INDEX resource (resource), INDEX get_method (get_method), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE customers_bundle__customer_type_translations ADD CONSTRAINT FK_AF7CDEC7232D562B FOREIGN KEY (object_id) REFERENCES customers_bundle__customer_type (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE sales_bundle__additional_pdf ADD CONSTRAINT FK_3CDB90D193CB796C FOREIGN KEY (file_id) REFERENCES file_manager (id)');
$this->addSql('ALTER TABLE sales_bundle__additional_pdf ADD CONSTRAINT FK_3CDB90D1B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE sales_bundle__additional_pdf ADD CONSTRAINT FK_3CDB90D1896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE sales_bundle__additional_pdf ADD CONSTRAINT FK_3CDB90D1C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE sales_bundle__customer_options ADD CONSTRAINT FK_5E01AC229395C3F3 FOREIGN KEY (customer_id) REFERENCES customers_bundle__customer (id)');
$this->addSql('ALTER TABLE sales_bundle__customer_options ADD CONSTRAINT FK_5E01AC22B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE sales_bundle__customer_options ADD CONSTRAINT FK_5E01AC22896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE sales_bundle__customer_options ADD CONSTRAINT FK_5E01AC22C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE suppliers_bundle__supplier_context ADD CONSTRAINT FK_CF412AA72ADD6D8C FOREIGN KEY (supplier_id) REFERENCES suppliers_bundle__supplier (id)');
$this->addSql('ALTER TABLE suppliers_bundle__supplier_context ADD CONSTRAINT FK_CF412AA76B00C1CF FOREIGN KEY (context_id) REFERENCES context (id)');
$this->addSql('ALTER TABLE webservice_key ADD CONSTRAINT FK_4AEB92AAB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE webservice_key ADD CONSTRAINT FK_4AEB92AA896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE webservice_key ADD CONSTRAINT FK_4AEB92AAC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE webservice_permission ADD CONSTRAINT FK_A9BE18AC601CEA4 FOREIGN KEY (webservice_key_id) REFERENCES webservice_key (id)');
$this->addSql('ALTER TABLE webservice_permission ADD CONSTRAINT FK_A9BE18AB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE webservice_permission ADD CONSTRAINT FK_A9BE18A896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE webservice_permission ADD CONSTRAINT FK_A9BE18AC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE categories_bundle__category ADD parent_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', ADD root_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', ADD lvl INT NOT NULL, ADD lft INT NOT NULL, ADD rgt INT NOT NULL');
$this->addSql('ALTER TABLE categories_bundle__category ADD CONSTRAINT FK_5504FB5727ACA70 FOREIGN KEY (parent_id) REFERENCES categories_bundle__category (id)');
$this->addSql('ALTER TABLE categories_bundle__category ADD CONSTRAINT FK_5504FB579066886 FOREIGN KEY (root_id) REFERENCES categories_bundle__category (id)');
$this->addSql('CREATE INDEX IDX_5504FB5727ACA70 ON categories_bundle__category (parent_id)');
$this->addSql('CREATE INDEX IDX_5504FB579066886 ON categories_bundle__category (root_id)');
$this->addSql('ALTER TABLE context ADD company_name VARCHAR(128) NOT NULL');
$this->addSql('ALTER TABLE currency CHANGE change_rate change_rate NUMERIC(20, 12) DEFAULT \'1\' NOT NULL');
$this->addSql('ALTER TABLE customers_bundle__customer ADD currency_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', ADD siret VARCHAR(16) DEFAULT NULL');
$this->addSql('ALTER TABLE customers_bundle__customer ADD CONSTRAINT FK_1FD6BD9538248176 FOREIGN KEY (currency_id) REFERENCES currency (id)');
$this->addSql('CREATE INDEX IDX_1FD6BD9538248176 ON customers_bundle__customer (currency_id)');
$this->addSql('ALTER TABLE products_bundle__product ADD changeable_tax_rule TINYINT(1) NOT NULL');
$this->addSql('CREATE INDEX reference_brand ON products_bundle__product (reference_brand)');
$this->addSql('ALTER TABLE sales_bundle__credit_note ADD reduced_vat TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE sales_bundle__credit_note_line ADD reference_brand VARCHAR(128) DEFAULT NULL, ADD wholesale_price NUMERIC(20, 6) DEFAULT NULL, ADD margin_ratio NUMERIC(20, 6) DEFAULT NULL');
$this->addSql('ALTER TABLE sales_bundle__invoice ADD reduced_vat TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE sales_bundle__invoice_line ADD reference_brand VARCHAR(128) DEFAULT NULL, ADD wholesale_price NUMERIC(20, 6) DEFAULT NULL, ADD margin_ratio NUMERIC(20, 6) DEFAULT NULL');
$this->addSql('ALTER TABLE sales_bundle__order ADD reduced_vat TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE sales_bundle__order_line ADD reference_brand VARCHAR(128) DEFAULT NULL, ADD wholesale_price NUMERIC(20, 6) DEFAULT NULL, ADD margin_ratio NUMERIC(20, 6) DEFAULT NULL');
$this->addSql('ALTER TABLE sales_bundle__quotation ADD reduced_vat TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE sales_bundle__quotation_line ADD reference_brand VARCHAR(128) DEFAULT NULL, ADD wholesale_price NUMERIC(20, 6) DEFAULT NULL, ADD margin_ratio NUMERIC(20, 6) DEFAULT NULL');
$this->addSql('ALTER TABLE suppliers_bundle__supplier ADD address2 VARCHAR(255) DEFAULT NULL, CHANGE address address VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE suppliers_bundle__supplier_type ADD number INT DEFAULT NULL');
$this->addSql('ALTER TABLE user ADD mobile_phone VARCHAR(32) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE webservice_permission DROP FOREIGN KEY FK_A9BE18AC601CEA4');
$this->addSql('DROP TABLE customers_bundle__customer_type_translations');
$this->addSql('DROP TABLE sales_bundle__additional_pdf');
$this->addSql('DROP TABLE sales_bundle__customer_options');
$this->addSql('DROP TABLE suppliers_bundle__supplier_context');
$this->addSql('DROP TABLE webservice_key');
$this->addSql('DROP TABLE webservice_permission');
$this->addSql('ALTER TABLE categories_bundle__category DROP FOREIGN KEY FK_5504FB5727ACA70');
$this->addSql('ALTER TABLE categories_bundle__category DROP FOREIGN KEY FK_5504FB579066886');
$this->addSql('DROP INDEX IDX_5504FB5727ACA70 ON categories_bundle__category');
$this->addSql('DROP INDEX IDX_5504FB579066886 ON categories_bundle__category');
$this->addSql('ALTER TABLE categories_bundle__category DROP parent_id, DROP root_id, DROP lvl, DROP lft, DROP rgt');
$this->addSql('ALTER TABLE context DROP company_name');
$this->addSql('ALTER TABLE currency CHANGE change_rate change_rate NUMERIC(20, 12) DEFAULT \'1.000000000000\' NOT NULL');
$this->addSql('ALTER TABLE customers_bundle__customer DROP FOREIGN KEY FK_1FD6BD9538248176');
$this->addSql('DROP INDEX IDX_1FD6BD9538248176 ON customers_bundle__customer');
$this->addSql('ALTER TABLE customers_bundle__customer DROP currency_id, DROP siret');
$this->addSql('DROP INDEX reference_brand ON products_bundle__product');
$this->addSql('ALTER TABLE products_bundle__product DROP changeable_tax_rule');
$this->addSql('ALTER TABLE sales_bundle__credit_note DROP reduced_vat');
$this->addSql('ALTER TABLE sales_bundle__credit_note_line DROP reference_brand, DROP wholesale_price, DROP margin_ratio');
$this->addSql('ALTER TABLE sales_bundle__invoice DROP reduced_vat');
$this->addSql('ALTER TABLE sales_bundle__invoice_line DROP reference_brand, DROP wholesale_price, DROP margin_ratio');
$this->addSql('ALTER TABLE sales_bundle__order DROP reduced_vat');
$this->addSql('ALTER TABLE sales_bundle__order_line DROP reference_brand, DROP wholesale_price, DROP margin_ratio');
$this->addSql('ALTER TABLE sales_bundle__quotation DROP reduced_vat');
$this->addSql('ALTER TABLE sales_bundle__quotation_line DROP reference_brand, DROP wholesale_price, DROP margin_ratio');
$this->addSql('ALTER TABLE suppliers_bundle__supplier DROP address2, CHANGE address address LONGTEXT DEFAULT NULL');
$this->addSql('ALTER TABLE suppliers_bundle__supplier_type DROP number');
$this->addSql('ALTER TABLE user DROP mobile_phone');
}
}