<?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 Version20210621115728 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 cal_maintenance (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, category_id INT DEFAULT NULL, comment LONGTEXT DEFAULT NULL, created_at DATETIME DEFAULT NULL, INDEX IDX_BE7ADFFA76ED395 (user_id), INDEX IDX_BE7ADFF12469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE cal_maintenance_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, position INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE cal_maintenance_category_choices (maintenance_category_source INT NOT NULL, maintenance_category_target INT NOT NULL, INDEX IDX_E965C0C21CFD24E0 (maintenance_category_source), INDEX IDX_E965C0C2518746F (maintenance_category_target), PRIMARY KEY(maintenance_category_source, maintenance_category_target)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE cal_maintenance ADD CONSTRAINT FK_BE7ADFFA76ED395 FOREIGN KEY (user_id) REFERENCES cal_user (id)');
$this->addSql('ALTER TABLE cal_maintenance ADD CONSTRAINT FK_BE7ADFF12469DE2 FOREIGN KEY (category_id) REFERENCES cal_maintenance_category (id)');
$this->addSql('ALTER TABLE cal_maintenance_category_choices ADD CONSTRAINT FK_E965C0C21CFD24E0 FOREIGN KEY (maintenance_category_source) REFERENCES cal_maintenance_category (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE cal_maintenance_category_choices ADD CONSTRAINT FK_E965C0C2518746F FOREIGN KEY (maintenance_category_target) REFERENCES cal_maintenance_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 cal_maintenance DROP FOREIGN KEY FK_BE7ADFF12469DE2');
$this->addSql('ALTER TABLE cal_maintenance_category_choices DROP FOREIGN KEY FK_E965C0C21CFD24E0');
$this->addSql('ALTER TABLE cal_maintenance_category_choices DROP FOREIGN KEY FK_E965C0C2518746F');
$this->addSql('DROP TABLE cal_maintenance');
$this->addSql('DROP TABLE cal_maintenance_category');
$this->addSql('DROP TABLE cal_maintenance_category_choices');
}
}