<?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 Version20230426140434 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 std_snippets (id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Snippet unique identifier\', created_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', updated_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', name VARCHAR(100) DEFAULT NULL COMMENT \'Snippet name\', is_active TINYINT(1) DEFAULT 1 NOT NULL COMMENT \'Flag that indicates if the snippet is active\', created_date DATETIME NOT NULL COMMENT \'Date and time of the record creation\', updated_date DATETIME NOT NULL COMMENT \'Date and time the record was last updated\', layout VARCHAR(100) DEFAULT NULL COMMENT \'Snippet layout\', machine_name VARCHAR(255) DEFAULT NULL, INDEX fk_std_snippets_std_users (created_by), INDEX fk_std_snippets_std_users_0 (updated_by), INDEX idx_machine_name (machine_name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE std_snippets_content (snippet_id INT UNSIGNED NOT NULL COMMENT \'Snippet unique identifier\', language_code VARCHAR(2) NOT NULL COMMENT \'ISO 639 Language code\', created_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', updated_by INT UNSIGNED DEFAULT NULL COMMENT \'Unique identifier\', is_active TINYINT(1) DEFAULT 1 NOT NULL COMMENT \'Flag that indicates if the content is active\', created_date DATETIME NOT NULL COMMENT \'Date and time of the record creation\', updated_date DATETIME NOT NULL COMMENT \'Date and time the record was last updated\', title VARCHAR(500) DEFAULT NULL, url VARCHAR(500) NOT NULL COMMENT \'Url of the snippet\', meta_title VARCHAR(150) DEFAULT NULL, meta_keywords VARCHAR(1000) DEFAULT NULL COMMENT \'Meta keywords of the snippet\', meta_description VARCHAR(255) DEFAULT NULL COMMENT \'Meta description of the snippet\', og_title VARCHAR(150) DEFAULT NULL COMMENT \'Open graph title of the snippet\', og_image VARCHAR(255) DEFAULT NULL COMMENT \'Open graph link to the image of the snippet\', og_description VARCHAR(300) DEFAULT NULL, og_url VARCHAR(255) DEFAULT NULL COMMENT \'Open graph url of the snippet\', canonical_url VARCHAR(500) DEFAULT NULL COMMENT \'Canonical URL\', scripts_head VARCHAR(255) DEFAULT NULL COMMENT \'Scripts to add to the head of the snippet\', scripts_body VARCHAR(255) DEFAULT NULL COMMENT \'Scripts to add to the body of the snippet\', scripts_footer VARCHAR(255) DEFAULT NULL COMMENT \'Scripts to add to the footer of the snippet\', content JSON DEFAULT NULL COMMENT \'Content of the snippet\', INDEX IDX_8398C8F06E34B975 (snippet_id), INDEX fk_std_snippets_content_std_users (created_by), INDEX fk_std_snippets_content_std_users_0 (updated_by), INDEX fk_std_snippets_content_std_languages (language_code), PRIMARY KEY(snippet_id, language_code)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE std_snippets ADD CONSTRAINT FK_snippets_created_by FOREIGN KEY (created_by) REFERENCES std_users (id)');
$this->addSql('ALTER TABLE std_snippets ADD CONSTRAINT FK_snippets_updated_by FOREIGN KEY (updated_by) REFERENCES std_users (id)');
$this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_snippets_content_snippet_id FOREIGN KEY (snippet_id) REFERENCES std_snippets (id)');
$this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_snippets_content_language_code FOREIGN KEY (language_code) REFERENCES std_languages (language_code)');
$this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_snippets_content_created_by FOREIGN KEY (created_by) REFERENCES std_users (id)');
$this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_FK_snippets_content_updated_by FOREIGN KEY (updated_by) REFERENCES std_users (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE std_snippets DROP FOREIGN KEY FK_snippets_created_by');
$this->addSql('ALTER TABLE std_snippets DROP FOREIGN KEY FK_snippets_updated_by');
$this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_snippets_content_snippet_id');
$this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_snippets_content_language_code');
$this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_snippets_content_created_by');
$this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_FK_snippets_content_updated_by');
$this->addSql('DROP TABLE std_snippets');
$this->addSql('DROP TABLE std_snippets_content');
}
}