<?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 Version20220624035622 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 news (id INT AUTO_INCREMENT NOT NULL, category_id INT NOT NULL, video_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, preview VARCHAR(255) NOT NULL, description VARCHAR(512) NOT NULL, detail_time VARCHAR(128) NOT NULL, public TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, link VARCHAR(255) NOT NULL, INDEX IDX_1DD3995012469DE2 (category_id), INDEX IDX_1DD3995029C1004E (video_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE news_news_tag (news_id INT NOT NULL, news_tag_id INT NOT NULL, INDEX IDX_F7007BF0B5A459A0 (news_id), INDEX IDX_F7007BF0367BA065 (news_tag_id), PRIMARY KEY(news_id, news_tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE news_static (id INT AUTO_INCREMENT NOT NULL, news_id INT NOT NULL, title VARCHAR(255) NOT NULL, filename VARCHAR(255) NOT NULL, INDEX IDX_C69EB51B5A459A0 (news_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD3995012469DE2 FOREIGN KEY (category_id) REFERENCES news_category (id)');
$this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD3995029C1004E FOREIGN KEY (video_id) REFERENCES video (id)');
$this->addSql('ALTER TABLE news_news_tag ADD CONSTRAINT FK_F7007BF0B5A459A0 FOREIGN KEY (news_id) REFERENCES news (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE news_news_tag ADD CONSTRAINT FK_F7007BF0367BA065 FOREIGN KEY (news_tag_id) REFERENCES news_tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE news_static ADD CONSTRAINT FK_C69EB51B5A459A0 FOREIGN KEY (news_id) REFERENCES news (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE news_news_tag DROP FOREIGN KEY FK_F7007BF0B5A459A0');
$this->addSql('ALTER TABLE news_static DROP FOREIGN KEY FK_C69EB51B5A459A0');
$this->addSql('ALTER TABLE news DROP FOREIGN KEY FK_1DD3995029C1004E');
$this->addSql('DROP TABLE news');
$this->addSql('DROP TABLE news_news_tag');
$this->addSql('DROP TABLE news_static');
}
}