<?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 Version20250930082349 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create epg table';
}
public function up(Schema $schema): void
{
$now = (new \DateTime())->format('Y-m-d H:i:s');
$this->addSql('CREATE TABLE clw_epg (
id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'EPG unique identifier\',
page_id INT UNSIGNED DEFAULT NULL,
is_active TINYINT(1) DEFAULT 1 NOT NULL COMMENT \'Is active\',
air_date DATE NOT NULL COMMENT \'Broadcast start date\',
end_date DATE DEFAULT NULL COMMENT \'Broadcast end date\',
epg_data JSON NOT NULL COMMENT \'EPG programs data in JSON format\',
UNIQUE INDEX UNIQ_326DE1CAC4663E4 (page_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE clw_epg ADD CONSTRAINT FK_326DE1CAC4663E4 FOREIGN KEY (page_id) REFERENCES std_pages (id) ON DELETE SET NULL');
$this->addSql("
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)
VALUES
(1, 1, 'epgs', 13, 'admin_epgs', 1, '$now', '$now', 'navigation', null, 'blog', 'epgs', null);
");
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE clw_epg DROP FOREIGN KEY FK_326DE1CAC4663E4');
$this->addSql('DROP TABLE clw_epg');
$this->addSql('DELETE FROM std_options WHERE machine_name = \'epgs\'');
}
}