migrations/Version20241018090000.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 Version20241018090000 extends AbstractMigration
    {
        public function getDescription(): string
        {
            return 'Create candidate_communication table if it does not already exist (idempotent fix)';
        }
    
        public function up(Schema $schema): void
        {
            if ($schema->hasTable('candidate_communication')) {
                return;
            }
    
            $table = $schema->createTable('candidate_communication');
            $table->addColumn('id', 'integer', ['autoincrement' => true]);
            $table->addColumn('title', 'string', ['length' => 255]);
            $table->addColumn('category', 'string', ['length' => 50]);
            $table->addColumn('recipients', 'json');
            $table->addColumn('message', 'text');
            $table->addColumn('scheduled_at', 'datetime_immutable', ['notnull' => false]);
            $table->addColumn('metadata', 'json');
            $table->addColumn('created_at', 'datetime_immutable');
            $table->setPrimaryKey(['id']);
            $table->addIndex(['category'], 'idx_candidate_communication_category');
            $table->addIndex(['scheduled_at'], 'idx_candidate_communication_schedule');
        }
    
        public function down(Schema $schema): void
        {
            if ($schema->hasTable('candidate_communication')) {
                $schema->dropTable('candidate_communication');
            }
        }
    }