src/Migrations/Version20230302131234.php line 1

  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 Version20230302131234 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 smi_item (id INT AUTO_INCREMENT NOT NULL, created_by_id INT DEFAULT NULL, updated_by_id INT DEFAULT NULL, link VARCHAR(255) DEFAULT NULL, publish_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', deleted TINYINT(1) DEFAULT 0 NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, weight INT DEFAULT 10 NOT NULL, active TINYINT(1) DEFAULT 1 NOT NULL, owner_uuid VARCHAR(36) DEFAULT NULL, owner_active TINYINT(1) DEFAULT 1 NOT NULL, owner_deleted TINYINT(1) DEFAULT 0 NOT NULL, INDEX IDX_67B98B5B03A8386 (created_by_id), INDEX IDX_67B98B5896DBBDE (updated_by_id), INDEX idx_active (deleted, active, weight  DESC, publish_at  DESC), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE smi_item_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, caption VARCHAR(255) DEFAULT NULL, text LONGTEXT DEFAULT NULL, locale VARCHAR(5) NOT NULL, INDEX IDX_18FECE912C2AC5D3 (translatable_id), UNIQUE INDEX smi_item_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE smi_item ADD CONSTRAINT FK_67B98B5B03A8386 FOREIGN KEY (created_by_id) REFERENCES users (id) ON DELETE SET NULL');
  21.         $this->addSql('ALTER TABLE smi_item ADD CONSTRAINT FK_67B98B5896DBBDE FOREIGN KEY (updated_by_id) REFERENCES users (id) ON DELETE SET NULL');
  22.         $this->addSql('ALTER TABLE smi_item_translation ADD CONSTRAINT FK_18FECE912C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES smi_item (id) ON DELETE CASCADE');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->addSql('ALTER TABLE smi_item DROP FOREIGN KEY FK_67B98B5B03A8386');
  28.         $this->addSql('ALTER TABLE smi_item DROP FOREIGN KEY FK_67B98B5896DBBDE');
  29.         $this->addSql('ALTER TABLE smi_item_translation DROP FOREIGN KEY FK_18FECE912C2AC5D3');
  30.         $this->addSql('DROP TABLE smi_item');
  31.         $this->addSql('DROP TABLE smi_item_translation');
  32.     }
  33. }