<?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 Version20220326211714 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 language (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', status TINYINT(1) NOT NULL, flag VARCHAR(255) DEFAULT NULL, INDEX IDX_D4DB71B5A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE language_post (language_id INT NOT NULL, post_id INT NOT NULL, INDEX IDX_688386C182F1BAF4 (language_id), INDEX IDX_688386C14B89032C (post_id), PRIMARY KEY(language_id, post_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE language_category (language_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_6AEE41FB82F1BAF4 (language_id), INDEX IDX_6AEE41FB12469DE2 (category_id), PRIMARY KEY(language_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE media (id INT AUTO_INCREMENT NOT NULL, post_id INT DEFAULT NULL, user_id INT DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, description LONGTEXT DEFAULT NULL, is_post TINYINT(1) DEFAULT NULL, download INT DEFAULT NULL, is_active TINYINT(1) NOT NULL, slug VARCHAR(255) DEFAULT NULL, view INT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_6A2CA10C4B89032C (post_id), INDEX IDX_6A2CA10CA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE language ADD CONSTRAINT FK_D4DB71B5A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE language_post ADD CONSTRAINT FK_688386C182F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE language_post ADD CONSTRAINT FK_688386C14B89032C FOREIGN KEY (post_id) REFERENCES post (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE language_category ADD CONSTRAINT FK_6AEE41FB82F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE language_category ADD CONSTRAINT FK_6AEE41FB12469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE media ADD CONSTRAINT FK_6A2CA10C4B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
$this->addSql('ALTER TABLE media ADD CONSTRAINT FK_6A2CA10CA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE category ADD view INT DEFAULT NULL, ADD lang VARCHAR(20) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE language_post DROP FOREIGN KEY FK_688386C182F1BAF4');
$this->addSql('ALTER TABLE language_category DROP FOREIGN KEY FK_6AEE41FB82F1BAF4');
$this->addSql('DROP TABLE language');
$this->addSql('DROP TABLE language_post');
$this->addSql('DROP TABLE language_category');
$this->addSql('DROP TABLE media');
$this->addSql('ALTER TABLE category DROP view, DROP lang');
}
}