<?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 Version20220712153345 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 header_menu (id INT AUTO_INCREMENT NOT NULL, static_page_id INT DEFAULT NULL, position INT UNSIGNED DEFAULT NULL, type SMALLINT NOT NULL, link VARCHAR(191) DEFAULT NULL, slug VARCHAR(191) DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, active SMALLINT DEFAULT 0 NOT NULL, INDEX IDX_D081401E95C43776 (static_page_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE header_menu_translations (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, locale VARCHAR(10) NOT NULL, INDEX IDX_B10C0A22C2AC5D3 (translatable_id), UNIQUE INDEX header_menu_translations_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE static_pages (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, meta_image_id INT DEFAULT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, active SMALLINT DEFAULT 0 NOT NULL, slug VARCHAR(191) NOT NULL, title_for_slug VARCHAR(191) NOT NULL, UNIQUE INDEX UNIQ_9BE40C2F989D9B62 (slug), INDEX IDX_9BE40C2F727ACA70 (parent_id), INDEX IDX_9BE40C2F73E8DD26 (meta_image_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE static_pages_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, locale VARCHAR(10) NOT NULL, title VARCHAR(191) DEFAULT NULL, content LONGTEXT DEFAULT NULL, meta_title VARCHAR(191) DEFAULT NULL, meta_keywords VARCHAR(191) DEFAULT NULL, meta_description LONGTEXT DEFAULT NULL, meta_canonical VARCHAR(191) DEFAULT NULL, INDEX IDX_FCA250372C2AC5D3 (translatable_id), UNIQUE INDEX static_pages_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE header_menu ADD CONSTRAINT FK_D081401E95C43776 FOREIGN KEY (static_page_id) REFERENCES static_pages (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE header_menu_translations ADD CONSTRAINT FK_B10C0A22C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES header_menu (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE static_pages ADD CONSTRAINT FK_9BE40C2F727ACA70 FOREIGN KEY (parent_id) REFERENCES static_pages (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE static_pages ADD CONSTRAINT FK_9BE40C2F73E8DD26 FOREIGN KEY (meta_image_id) REFERENCES media__media (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE static_pages_translation ADD CONSTRAINT FK_FCA250372C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES static_pages (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE media__media CHANGE provider_metadata provider_metadata JSON DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE header_menu_translations DROP FOREIGN KEY FK_B10C0A22C2AC5D3');
$this->addSql('ALTER TABLE header_menu DROP FOREIGN KEY FK_D081401E95C43776');
$this->addSql('ALTER TABLE static_pages DROP FOREIGN KEY FK_9BE40C2F727ACA70');
$this->addSql('ALTER TABLE static_pages_translation DROP FOREIGN KEY FK_FCA250372C2AC5D3');
$this->addSql('DROP TABLE header_menu');
$this->addSql('DROP TABLE header_menu_translations');
$this->addSql('DROP TABLE static_pages');
$this->addSql('DROP TABLE static_pages_translation');
$this->addSql('ALTER TABLE media__media CHANGE provider_metadata provider_metadata JSON DEFAULT NULL');
}
}