<?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 Version20220117114005 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 category (id VARCHAR(255) NOT NULL, name VARCHAR(80) NOT NULL, slug VARCHAR(80) NOT NULL, woo_commerce_id INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE client (id VARCHAR(255) NOT NULL, name VARCHAR(100) NOT NULL, address VARCHAR(100) NOT NULL, phone VARCHAR(50) NOT NULL, city VARCHAR(50) NOT NULL, mail VARCHAR(100) NOT NULL, vat_number VARCHAR(100) NOT NULL, sales_rep_id1 INT NOT NULL, imported TINYINT(1) NOT NULL, permission_level INT NOT NULL, force_manager_id INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE contact (id VARCHAR(255) NOT NULL, client_id VARCHAR(255) DEFAULT NULL, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, email VARCHAR(100) DEFAULT NULL, phone1 VARCHAR(100) DEFAULT NULL, address1 VARCHAR(100) DEFAULT NULL, force_manager_id INT DEFAULT NULL, imported TINYINT(1) NOT NULL, permission_level INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_4C62E63819EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE offer (id VARCHAR(255) NOT NULL, contact_id VARCHAR(255) DEFAULT NULL, client_id VARCHAR(255) DEFAULT NULL, date DATETIME NOT NULL, invoice_number INT NOT NULL, code VARCHAR(100) NOT NULL, status VARCHAR(100) NOT NULL, total_price DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_29D6873EE7A1254A (contact_id), INDEX IDX_29D6873E19EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE offer_line (id VARCHAR(255) NOT NULL, offer_id VARCHAR(255) DEFAULT NULL, product_id VARCHAR(255) DEFAULT NULL, quantity INT NOT NULL, price DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_2FEC9AE153C674EE (offer_id), INDEX IDX_2FEC9AE14584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product (id VARCHAR(255) NOT NULL, sku VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, short_description VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, supplier VARCHAR(255) NOT NULL, regular_price DOUBLE PRECISION DEFAULT NULL, tools VARCHAR(255) NOT NULL, purchase_date DATE DEFAULT NULL, purchase_price DOUBLE PRECISION DEFAULT NULL, sale_date DATE DEFAULT NULL, invoice_number VARCHAR(255) NOT NULL, stock TINYINT(1) NOT NULL, client VARCHAR(255) NOT NULL, type VARCHAR(50) NOT NULL, imported TINYINT(1) NOT NULL, woo_commerce_id INT DEFAULT NULL, catalog_visibility VARCHAR(50) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_D34A04ADF9038C4 (sku), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE product_category (product_id VARCHAR(255) NOT NULL, category_id VARCHAR(255) NOT NULL, INDEX IDX_CDFC73564584665A (product_id), INDEX IDX_CDFC735612469DE2 (category_id), PRIMARY KEY(product_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id VARCHAR(255) NOT NULL, username VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE contact ADD CONSTRAINT FK_4C62E63819EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE offer ADD CONSTRAINT FK_29D6873EE7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id)');
$this->addSql('ALTER TABLE offer ADD CONSTRAINT FK_29D6873E19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE offer_line ADD CONSTRAINT FK_2FEC9AE153C674EE FOREIGN KEY (offer_id) REFERENCES offer (id)');
$this->addSql('ALTER TABLE offer_line ADD CONSTRAINT FK_2FEC9AE14584665A FOREIGN KEY (product_id) REFERENCES product (id)');
$this->addSql('ALTER TABLE product_category ADD CONSTRAINT FK_CDFC73564584665A FOREIGN KEY (product_id) REFERENCES product (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE product_category ADD CONSTRAINT FK_CDFC735612469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE product_category DROP FOREIGN KEY FK_CDFC735612469DE2');
$this->addSql('ALTER TABLE contact DROP FOREIGN KEY FK_4C62E63819EB6921');
$this->addSql('ALTER TABLE offer DROP FOREIGN KEY FK_29D6873E19EB6921');
$this->addSql('ALTER TABLE offer DROP FOREIGN KEY FK_29D6873EE7A1254A');
$this->addSql('ALTER TABLE offer_line DROP FOREIGN KEY FK_2FEC9AE153C674EE');
$this->addSql('ALTER TABLE offer_line DROP FOREIGN KEY FK_2FEC9AE14584665A');
$this->addSql('ALTER TABLE product_category DROP FOREIGN KEY FK_CDFC73564584665A');
$this->addSql('DROP TABLE category');
$this->addSql('DROP TABLE client');
$this->addSql('DROP TABLE contact');
$this->addSql('DROP TABLE offer');
$this->addSql('DROP TABLE offer_line');
$this->addSql('DROP TABLE product');
$this->addSql('DROP TABLE product_category');
$this->addSql('DROP TABLE user');
}
}