migrations/Version20250930082349.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 Version20250930082349 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Create epg table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $now = (new \DateTime())->format('Y-m-d H:i:s');
  18.         $this->addSql('CREATE TABLE clw_epg (
  19.             id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'EPG unique identifier\', 
  20.             page_id INT UNSIGNED DEFAULT NULL, 
  21.             is_active TINYINT(1) DEFAULT 1 NOT NULL COMMENT \'Is active\', 
  22.             air_date DATE NOT NULL COMMENT \'Broadcast start date\', 
  23.             end_date DATE DEFAULT NULL COMMENT \'Broadcast end date\', 
  24.             epg_data JSON NOT NULL COMMENT \'EPG programs data in JSON format\', 
  25.             UNIQUE INDEX UNIQ_326DE1CAC4663E4 (page_id), 
  26.             PRIMARY KEY(id)
  27.         ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  28.         
  29.         $this->addSql('ALTER TABLE clw_epg ADD CONSTRAINT FK_326DE1CAC4663E4 FOREIGN KEY (page_id) REFERENCES std_pages (id) ON DELETE SET NULL');
  30.         
  31.         $this->addSql("
  32.             INSERT IGNORE INTO std_options (created_by, updated_by, machine_name, order_value, path, is_active, created_date, updated_date, menu_section, dropdown_section, icon, name, external_link)
  33.             VALUES           
  34.             (1, 1, 'epgs', 13, 'admin_epgs', 1, '$now', '$now', 'navigation', null, 'blog', 'epgs', null);
  35.         ");
  36.     }
  37.     public function down(Schema $schema): void
  38.     {
  39.         $this->addSql('ALTER TABLE clw_epg DROP FOREIGN KEY FK_326DE1CAC4663E4');
  40.         $this->addSql('DROP TABLE clw_epg');
  41.         $this->addSql('DELETE FROM std_options WHERE machine_name = \'epgs\'');
  42.     }
  43. }