<?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 Version20220831110834 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 articles_discount_groups (articles_id INT NOT NULL, discount_groups_id INT NOT NULL, INDEX IDX_4F19D37B1EBAF6CC (articles_id), INDEX IDX_4F19D37B6FEDB532 (discount_groups_id), PRIMARY KEY(articles_id, discount_groups_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE articles_item_groups (articles_id INT NOT NULL, item_groups_id INT NOT NULL, INDEX IDX_D2A17BDE1EBAF6CC (articles_id), INDEX IDX_D2A17BDE3ED2B3F (item_groups_id), PRIMARY KEY(articles_id, item_groups_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE discount_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE item_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE order_article (id INT AUTO_INCREMENT NOT NULL, order_cart_id INT DEFAULT NULL, article_id INT DEFAULT NULL, created_by_id INT DEFAULT NULL, quantity DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_F440A72DECAF64F4 (order_cart_id), INDEX IDX_F440A72D7294869C (article_id), INDEX IDX_F440A72DB03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE order_status (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, id_punch INT DEFAULT NULL, priority INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE orders (id INT AUTO_INCREMENT NOT NULL, establishment_id INT DEFAULT NULL, validated_by_id INT DEFAULT NULL, status_id INT DEFAULT NULL, id_punch INT DEFAULT NULL, comment LONGTEXT DEFAULT NULL, delivered TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, delivery_date DATETIME DEFAULT NULL, validated TINYINT(1) NOT NULL, validated_at DATETIME DEFAULT NULL, INDEX IDX_E52FFDEE8565851 (establishment_id), INDEX IDX_E52FFDEEC69DE5E5 (validated_by_id), INDEX IDX_E52FFDEE6BF700BD (status_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE shopping_cart (id INT AUTO_INCREMENT NOT NULL, article_id INT DEFAULT NULL, establishment_id INT DEFAULT NULL, created_by_id INT DEFAULT NULL, quantity DOUBLE PRECISION NOT NULL, price_unit DOUBLE PRECISION NOT NULL, tax DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_72AAD4F67294869C (article_id), INDEX IDX_72AAD4F68565851 (establishment_id), INDEX IDX_72AAD4F6B03A8386 (created_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE articles_discount_groups ADD CONSTRAINT FK_4F19D37B1EBAF6CC FOREIGN KEY (articles_id) REFERENCES articles (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE articles_discount_groups ADD CONSTRAINT FK_4F19D37B6FEDB532 FOREIGN KEY (discount_groups_id) REFERENCES discount_groups (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE articles_item_groups ADD CONSTRAINT FK_D2A17BDE1EBAF6CC FOREIGN KEY (articles_id) REFERENCES articles (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE articles_item_groups ADD CONSTRAINT FK_D2A17BDE3ED2B3F FOREIGN KEY (item_groups_id) REFERENCES item_groups (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE order_article ADD CONSTRAINT FK_F440A72DECAF64F4 FOREIGN KEY (order_cart_id) REFERENCES orders (id)');
$this->addSql('ALTER TABLE order_article ADD CONSTRAINT FK_F440A72D7294869C FOREIGN KEY (article_id) REFERENCES articles (id)');
$this->addSql('ALTER TABLE order_article ADD CONSTRAINT FK_F440A72DB03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEE8565851 FOREIGN KEY (establishment_id) REFERENCES establishments (id)');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEEC69DE5E5 FOREIGN KEY (validated_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE orders ADD CONSTRAINT FK_E52FFDEE6BF700BD FOREIGN KEY (status_id) REFERENCES order_status (id)');
$this->addSql('ALTER TABLE shopping_cart ADD CONSTRAINT FK_72AAD4F67294869C FOREIGN KEY (article_id) REFERENCES articles (id)');
$this->addSql('ALTER TABLE shopping_cart ADD CONSTRAINT FK_72AAD4F68565851 FOREIGN KEY (establishment_id) REFERENCES establishments (id)');
$this->addSql('ALTER TABLE shopping_cart ADD CONSTRAINT FK_72AAD4F6B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE articles_discount_groups DROP FOREIGN KEY FK_4F19D37B1EBAF6CC');
$this->addSql('ALTER TABLE articles_discount_groups DROP FOREIGN KEY FK_4F19D37B6FEDB532');
$this->addSql('ALTER TABLE articles_item_groups DROP FOREIGN KEY FK_D2A17BDE1EBAF6CC');
$this->addSql('ALTER TABLE articles_item_groups DROP FOREIGN KEY FK_D2A17BDE3ED2B3F');
$this->addSql('ALTER TABLE order_article DROP FOREIGN KEY FK_F440A72DECAF64F4');
$this->addSql('ALTER TABLE order_article DROP FOREIGN KEY FK_F440A72D7294869C');
$this->addSql('ALTER TABLE order_article DROP FOREIGN KEY FK_F440A72DB03A8386');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEE8565851');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEEC69DE5E5');
$this->addSql('ALTER TABLE orders DROP FOREIGN KEY FK_E52FFDEE6BF700BD');
$this->addSql('ALTER TABLE shopping_cart DROP FOREIGN KEY FK_72AAD4F67294869C');
$this->addSql('ALTER TABLE shopping_cart DROP FOREIGN KEY FK_72AAD4F68565851');
$this->addSql('ALTER TABLE shopping_cart DROP FOREIGN KEY FK_72AAD4F6B03A8386');
$this->addSql('DROP TABLE articles_discount_groups');
$this->addSql('DROP TABLE articles_item_groups');
$this->addSql('DROP TABLE discount_groups');
$this->addSql('DROP TABLE item_groups');
$this->addSql('DROP TABLE order_article');
$this->addSql('DROP TABLE order_status');
$this->addSql('DROP TABLE orders');
$this->addSql('DROP TABLE shopping_cart');
}
}