migrations/Version20241022090000.php line 1

Open in your IDE?
  1. <?php
    
    declare(strict_types=1);
    
    namespace DoctrineMigrations;
    
    use Doctrine\DBAL\Schema\Schema;
    use Doctrine\Migrations\AbstractMigration;
    
    final class Version20241022090000 extends AbstractMigration
    {
        public function getDescription(): string
        {
            return 'Guarantee candidate_communication table exists using raw SQL for MySQL environments';
        }
    
        public function up(Schema $schema): void
        {
            if ('mysql' !== $this->connection->getDatabasePlatform()->getName()) {
                return;
            }
    
            $this->addSql(<<<'SQL'
    CREATE TABLE IF NOT EXISTS candidate_communication (
        id INT AUTO_INCREMENT NOT NULL,
        title VARCHAR(255) NOT NULL,
        category VARCHAR(50) NOT NULL,
        recipients JSON NOT NULL,
        message LONGTEXT NOT NULL,
        scheduled_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)',
        metadata JSON NOT NULL,
        created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)',
        INDEX idx_candidate_communication_category (category),
        INDEX idx_candidate_communication_schedule (scheduled_at),
        PRIMARY KEY(id)
    ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
    SQL);
        }
    
        public function down(Schema $schema): void
        {
            if ('mysql' !== $this->connection->getDatabasePlatform()->getName()) {
                return;
            }
    
            $this->addSql('DROP TABLE IF EXISTS candidate_communication');
        }
    }