<?php declare(strict_types = 1);
namespace DoctrineMigrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180502071849 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE frontend_category DROP FOREIGN KEY FK_CA9F8727D721B647');
$this->addSql('ALTER TABLE frontendcategory_productcategories DROP FOREIGN KEY FK_9B8708E5D721B647');
// These tables were not really used...
$this->addSql('DROP TABLE checking_account_payment');
$this->addSql('DROP TABLE measurementUnits');
$this->addSql('DROP TABLE orderSubItems');
$this->addSql('DROP TABLE orderItems');
// We are killing some frontend features...
$this->addSql('DROP TABLE frontend_category');
$this->addSql('DROP TABLE frontendcategory_productcategories');
$this->addSql('DROP TABLE frontend_new');
// Cleanup
$this->addSql('ALTER TABLE clients DROP discr');
$this->addSql('ALTER TABLE orders DROP INDEX IDX_E52FFDEEDBC5F284, ADD UNIQUE INDEX UNIQ_E52FFDEEDBC5F284 (facturation_id)');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEEC6B1F05C');
$this->addSql('DROP INDEX IDX_E52FFDEEC6B1F05C ON orders');
$this->addSql('ALTER TABLE orders DROP discr');
$this->addSql('ALTER TABLE productsForSale DROP discr');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE checking_account_payment (id INT AUTO_INCREMENT NOT NULL, authorizationCode VARCHAR(50) DEFAULT NULL COLLATE utf8_unicode_ci, total NUMERIC(10, 2) NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL, idClient INT DEFAULT NULL, idPaymentMethod INT DEFAULT NULL, createdBy INT DEFAULT NULL, updatedBy INT DEFAULT NULL, INDEX IDX_5673CA3A455ACCF (idClient), INDEX IDX_5673CA34E60B956 (idPaymentMethod), INDEX IDX_5673CA3D3564642 (createdBy), INDEX IDX_5673CA3E8DE7170 (updatedBy), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE frontend_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL COLLATE utf8_unicode_ci, place INT NOT NULL, color VARCHAR(25) DEFAULT NULL COLLATE utf8_unicode_ci, color2 VARCHAR(25) DEFAULT NULL COLLATE utf8_unicode_ci, display TINYINT(1) NOT NULL, idImage INT DEFAULT NULL, idFrontendCategory INT DEFAULT NULL, discr VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, INDEX IDX_CA9F8727D2F94742 (idImage), INDEX IDX_CA9F8727D721B647 (idFrontendCategory), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE frontend_new (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL COLLATE utf8_unicode_ci, place INT NOT NULL, display TINYINT(1) NOT NULL, idImage INT DEFAULT NULL, discr VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, INDEX IDX_6AD2052D2F94742 (idImage), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE frontendcategory_productcategories (idFrontendCategory INT NOT NULL, idProductCategory INT NOT NULL, UNIQUE INDEX UNIQ_9B8708E533715F4D (idProductCategory), INDEX IDX_9B8708E5D721B647 (idFrontendCategory), PRIMARY KEY(idFrontendCategory, idProductCategory)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE measurementUnits (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100) NOT NULL COLLATE utf8_unicode_ci, abbr VARCHAR(20) NOT NULL COLLATE utf8_unicode_ci, plural VARCHAR(100) NOT NULL COLLATE utf8_unicode_ci, display TINYINT(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE orderSubItems (id INT AUTO_INCREMENT NOT NULL, quantity DOUBLE PRECISION NOT NULL, active TINYINT(1) DEFAULT \'1\' NOT NULL, idItem INT DEFAULT NULL, idBaseProduct INT DEFAULT NULL, INDEX IDX_212803F36CE67B80 (idItem), INDEX IDX_212803F3CDF9BDA3 (idBaseProduct), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE role (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(30) NOT NULL COLLATE utf8_unicode_ci, role VARCHAR(20) NOT NULL COLLATE utf8_unicode_ci, UNIQUE INDEX UNIQ_57698A6A57698A6A (role), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE checking_account_payment ADD CONSTRAINT FK_5673CA34E60B956 FOREIGN KEY (idPaymentMethod) REFERENCES payment_method (id)');
$this->addSql('ALTER TABLE checking_account_payment ADD CONSTRAINT FK_5673CA3A455ACCF FOREIGN KEY (idClient) REFERENCES clients (id)');
$this->addSql('ALTER TABLE checking_account_payment ADD CONSTRAINT FK_5673CA3D3564642 FOREIGN KEY (createdBy) REFERENCES users (id)');
$this->addSql('ALTER TABLE checking_account_payment ADD CONSTRAINT FK_5673CA3E8DE7170 FOREIGN KEY (updatedBy) REFERENCES users (id)');
$this->addSql('ALTER TABLE frontend_category ADD CONSTRAINT FK_CA9F8727D2F94742 FOREIGN KEY (idImage) REFERENCES attachments (id)');
$this->addSql('ALTER TABLE frontend_category ADD CONSTRAINT FK_CA9F8727D721B647 FOREIGN KEY (idFrontendCategory) REFERENCES frontend_category (id)');
$this->addSql('ALTER TABLE frontend_message ADD CONSTRAINT FK_695443CB3185884C FOREIGN KEY (answeredBy) REFERENCES users (id)');
$this->addSql('ALTER TABLE frontend_message ADD CONSTRAINT FK_695443CBD3564642 FOREIGN KEY (createdBy) REFERENCES users (id)');
$this->addSql('ALTER TABLE frontend_message ADD CONSTRAINT FK_695443CBE8DE7170 FOREIGN KEY (updatedBy) REFERENCES users (id)');
$this->addSql('ALTER TABLE frontend_new ADD CONSTRAINT FK_6AD2052D2F94742 FOREIGN KEY (idImage) REFERENCES attachments (id)');
$this->addSql('ALTER TABLE frontendcategory_productcategories ADD CONSTRAINT FK_9B8708E533715F4D FOREIGN KEY (idProductCategory) REFERENCES productCategories (id)');
$this->addSql('ALTER TABLE frontendcategory_productcategories ADD CONSTRAINT FK_9B8708E5D721B647 FOREIGN KEY (idFrontendCategory) REFERENCES frontend_category (id)');
$this->addSql('ALTER TABLE orderSubItems ADD CONSTRAINT FK_212803F36CE67B80 FOREIGN KEY (idItem) REFERENCES orderItems (id)');
$this->addSql('ALTER TABLE orderSubItems ADD CONSTRAINT FK_212803F3CDF9BDA3 FOREIGN KEY (idBaseProduct) REFERENCES baseProducts (id)');
$this->addSql('ALTER TABLE clients ADD discr VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
$this->addSql('ALTER TABLE orders DROP INDEX UNIQ_E52FFDEEDBC5F284, ADD INDEX IDX_E52FFDEEDBC5F284 (facturation_id)');
$this->addSql('ALTER TABLE orders ADD discr VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
$this->addSql('ALTER TABLE productsForSale ADD discr VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
}
}