migrations/Version20230426140434.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20230426140434 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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');
  19.         $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');
  20.         $this->addSql('ALTER TABLE std_snippets ADD CONSTRAINT FK_snippets_created_by FOREIGN KEY (created_by) REFERENCES std_users (id)');
  21.         $this->addSql('ALTER TABLE std_snippets ADD CONSTRAINT FK_snippets_updated_by FOREIGN KEY (updated_by) REFERENCES std_users (id)');
  22.         $this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_snippets_content_snippet_id FOREIGN KEY (snippet_id) REFERENCES std_snippets (id)');
  23.         $this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_snippets_content_language_code FOREIGN KEY (language_code) REFERENCES std_languages (language_code)');
  24.         $this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_snippets_content_created_by FOREIGN KEY (created_by) REFERENCES std_users (id)');
  25.         $this->addSql('ALTER TABLE std_snippets_content ADD CONSTRAINT FK_FK_snippets_content_updated_by FOREIGN KEY (updated_by) REFERENCES std_users (id)');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE std_snippets DROP FOREIGN KEY FK_snippets_created_by');
  31.         $this->addSql('ALTER TABLE std_snippets DROP FOREIGN KEY FK_snippets_updated_by');
  32.         $this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_snippets_content_snippet_id');
  33.         $this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_snippets_content_language_code');
  34.         $this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_snippets_content_created_by');
  35.         $this->addSql('ALTER TABLE std_snippets_content DROP FOREIGN KEY FK_FK_snippets_content_updated_by');
  36.         $this->addSql('DROP TABLE std_snippets');
  37.         $this->addSql('DROP TABLE std_snippets_content');
  38.     }
  39. }