<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220817071401 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 company (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(8) DEFAULT NULL, provision INT DEFAULT NULL, name VARCHAR(512) DEFAULT NULL, address VARCHAR(512) DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, town VARCHAR(128) DEFAULT NULL, postal VARCHAR(6) DEFAULT NULL, address2 VARCHAR(512) DEFAULT NULL, street2 VARCHAR(255) DEFAULT NULL, town2 VARCHAR(128) DEFAULT NULL, postal2 VARCHAR(6) DEFAULT NULL, ic VARCHAR(32) DEFAULT NULL, dic VARCHAR(36) DEFAULT NULL, phone VARCHAR(128) DEFAULT NULL, email VARCHAR(128) DEFAULT NULL, bank_name VARCHAR(255) DEFAULT NULL, bank_account VARCHAR(255) DEFAULT NULL, swift VARCHAR(128) DEFAULT NULL, iban VARCHAR(128) DEFAULT NULL, registration_place VARCHAR(255) DEFAULT NULL, registration_number VARCHAR(255) DEFAULT NULL, registration_partition VARCHAR(255) DEFAULT NULL, registration_insertion VARCHAR(255) DEFAULT NULL, representantive VARCHAR(255) DEFAULT NULL, notes LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `order` (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, merchant_id INT NOT NULL, company_id INT NOT NULL, hash VARCHAR(255) NOT NULL, merchant_code VARCHAR(255) DEFAULT NULL, product_count DOUBLE PRECISION NOT NULL, product_price DOUBLE PRECISION NOT NULL, product_tax DOUBLE PRECISION NOT NULL, name VARCHAR(128) DEFAULT NULL, surname VARCHAR(128) DEFAULT NULL, person_type VARCHAR(3) DEFAULT NULL, nationality VARCHAR(32) DEFAULT NULL, tax_residency VARCHAR(4) DEFAULT NULL, address VARCHAR(512) DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, town VARCHAR(128) DEFAULT NULL, postal VARCHAR(6) DEFAULT NULL, address2 VARCHAR(512) DEFAULT NULL, street2 VARCHAR(255) DEFAULT NULL, town2 VARCHAR(128) DEFAULT NULL, postal2 VARCHAR(6) DEFAULT NULL, ic VARCHAR(32) DEFAULT NULL, dic VARCHAR(36) DEFAULT NULL, birthdate DATE DEFAULT NULL, phone VARCHAR(128) DEFAULT NULL, email VARCHAR(128) DEFAULT NULL, bank_name VARCHAR(255) DEFAULT NULL, bank_account VARCHAR(255) DEFAULT NULL, swift VARCHAR(128) DEFAULT NULL, iban VARCHAR(128) DEFAULT NULL, id_type VARCHAR(255) DEFAULT NULL, id_number VARCHAR(255) DEFAULT NULL, id_author VARCHAR(255) DEFAULT NULL, id_validity VARCHAR(255) DEFAULT NULL, businessman_registration_place VARCHAR(255) DEFAULT NULL, businessman_registration_number VARCHAR(255) DEFAULT NULL, company_registration_place VARCHAR(255) DEFAULT NULL, company_registration_number VARCHAR(255) DEFAULT NULL, company_registration_partition VARCHAR(255) DEFAULT NULL, company_registration_insertion VARCHAR(255) DEFAULT NULL, company_representantive VARCHAR(255) DEFAULT NULL, sign_place VARCHAR(255) NOT NULL, message LONGTEXT DEFAULT NULL, consent1 TINYINT(1) NOT NULL, consent2 TINYINT(1) NOT NULL, consent3 TINYINT(1) NOT NULL, consent4 TINYINT(1) NOT NULL, consent5 TINYINT(1) NOT NULL, consent6 TINYINT(1) NOT NULL, INDEX IDX_F5299398A76ED395 (user_id), INDEX IDX_F52993986796D554 (merchant_id), INDEX IDX_F5299398979B1AD6 (company_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE order_product (order_id INT NOT NULL, product_id INT NOT NULL, INDEX IDX_2530ADE68D9F6D38 (order_id), INDEX IDX_2530ADE64584665A (product_id), PRIMARY KEY(order_id, product_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product (id INT AUTO_INCREMENT NOT NULL, company_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, price DOUBLE PRECISION NOT NULL, tax DOUBLE PRECISION NOT NULL, notes LONGTEXT DEFAULT NULL, INDEX IDX_D34A04AD979B1AD6 (company_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F5299398A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F52993986796D554 FOREIGN KEY (merchant_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F5299398979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
$this->addSql('ALTER TABLE order_product ADD CONSTRAINT FK_2530ADE68D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE order_product ADD CONSTRAINT FK_2530ADE64584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
$this->addSql('ALTER TABLE user ADD company_id INT DEFAULT NULL, ADD active TINYINT(1) DEFAULT NULL, ADD code VARCHAR(8) DEFAULT NULL, ADD provision INT DEFAULT NULL, ADD name VARCHAR(128) DEFAULT NULL, ADD surname VARCHAR(128) DEFAULT NULL, ADD person_type VARCHAR(3) DEFAULT NULL, ADD nationality VARCHAR(32) DEFAULT NULL, ADD tax_residency VARCHAR(4) DEFAULT NULL, ADD address VARCHAR(512) DEFAULT NULL, ADD street VARCHAR(255) DEFAULT NULL, ADD town VARCHAR(128) DEFAULT NULL, ADD postal VARCHAR(6) DEFAULT NULL, ADD address2 VARCHAR(512) DEFAULT NULL, ADD street2 VARCHAR(255) DEFAULT NULL, ADD town2 VARCHAR(128) DEFAULT NULL, ADD postal2 VARCHAR(6) DEFAULT NULL, ADD ic VARCHAR(32) DEFAULT NULL, ADD dic VARCHAR(36) DEFAULT NULL, ADD birthdate DATE DEFAULT NULL, ADD phone VARCHAR(128) DEFAULT NULL, ADD bank_name VARCHAR(255) DEFAULT NULL, ADD bank_account VARCHAR(255) DEFAULT NULL, ADD swift VARCHAR(128) DEFAULT NULL, ADD iban VARCHAR(128) DEFAULT NULL, ADD notes LONGTEXT DEFAULT NULL, ADD id_type VARCHAR(255) DEFAULT NULL, ADD id_number VARCHAR(255) DEFAULT NULL, ADD id_author VARCHAR(255) DEFAULT NULL, ADD id_validity VARCHAR(255) DEFAULT NULL, ADD businessman_registration_place VARCHAR(255) DEFAULT NULL, ADD businessman_registration_number VARCHAR(255) DEFAULT NULL, ADD company_registration_place VARCHAR(255) DEFAULT NULL, ADD company_registration_number VARCHAR(255) DEFAULT NULL, ADD company_registration_partition VARCHAR(255) DEFAULT NULL, ADD company_registration_insertion VARCHAR(255) DEFAULT NULL, ADD company_representantive VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D649979B1AD6 FOREIGN KEY (company_id) REFERENCES company (id)');
$this->addSql('CREATE INDEX IDX_8D93D649979B1AD6 ON user (company_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F5299398979B1AD6');
$this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD979B1AD6');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D649979B1AD6');
$this->addSql('ALTER TABLE order_product DROP FOREIGN KEY FK_2530ADE68D9F6D38');
$this->addSql('ALTER TABLE order_product DROP FOREIGN KEY FK_2530ADE64584665A');
$this->addSql('DROP TABLE company');
$this->addSql('DROP TABLE `order`');
$this->addSql('DROP TABLE order_product');
$this->addSql('DROP TABLE product');
$this->addSql('DROP INDEX IDX_8D93D649979B1AD6 ON user');
$this->addSql('ALTER TABLE user DROP company_id, DROP active, DROP code, DROP provision, DROP name, DROP surname, DROP person_type, DROP nationality, DROP tax_residency, DROP address, DROP street, DROP town, DROP postal, DROP address2, DROP street2, DROP town2, DROP postal2, DROP ic, DROP dic, DROP birthdate, DROP phone, DROP bank_name, DROP bank_account, DROP swift, DROP iban, DROP notes, DROP id_type, DROP id_number, DROP id_author, DROP id_validity, DROP businessman_registration_place, DROP businessman_registration_number, DROP company_registration_place, DROP company_registration_number, DROP company_registration_partition, DROP company_registration_insertion, DROP company_representantive');
}
}