migrations/Version20240926000000.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 Version20240926000000 extends AbstractMigration
    {
        public function getDescription(): string
        {
            return 'Add grade snapshots to application_processing_state to persist final and corrected scores';
        }
    
        public function up(Schema $schema): void
        {
            if ($schema->hasTable('application_processing_state')) {
                $table = $schema->getTable('application_processing_state');
    
                if (!$table->hasColumn('grade_snapshots')) {
                    $table->addColumn('grade_snapshots', 'json', ['notnull' => false]);
                }
            }
        }
    
        public function down(Schema $schema): void
        {
            if ($schema->hasTable('application_processing_state')) {
                $table = $schema->getTable('application_processing_state');
    
                if ($table->hasColumn('grade_snapshots')) {
                    $table->dropColumn('grade_snapshots');
                }
            }
        }
    }