<?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 Version20220106155833 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 card (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, kunde VARCHAR(255), auftrag VARCHAR(255) DEFAULT NULL, date DATE NOT NULL, umgesetzt TINYINT(1) NOT NULL, keywords VARCHAR(255) DEFAULT NULL, imagename VARCHAR(255) DEFAULT NULL, INDEX IDX_161498D3A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE card_category (card_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_BF7DD7424ACC9A20 (card_id), INDEX IDX_BF7DD74212469DE2 (category_id), PRIMARY KEY(card_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE category (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_64C19C1A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE card ADD CONSTRAINT FK_161498D3A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE card_category ADD CONSTRAINT FK_BF7DD7424ACC9A20 FOREIGN KEY (card_id) REFERENCES card (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE card_category ADD CONSTRAINT FK_BF7DD74212469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE category ADD CONSTRAINT FK_64C19C1A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE card_category DROP FOREIGN KEY FK_BF7DD7424ACC9A20');
$this->addSql('ALTER TABLE card_category DROP FOREIGN KEY FK_BF7DD74212469DE2');
$this->addSql('ALTER TABLE card DROP FOREIGN KEY FK_161498D3A76ED395');
$this->addSql('ALTER TABLE category DROP FOREIGN KEY FK_64C19C1A76ED395');
$this->addSql('DROP TABLE card');
$this->addSql('DROP TABLE card_category');
$this->addSql('DROP TABLE category');
$this->addSql('DROP TABLE user');
}
}