import { QueryInterface } from 'sequelize';

/**
 * Migration to update any workflow requests with IN_PROGRESS status to PENDING
 * Since IN_PROGRESS is essentially the same as PENDING for workflow requests
 */
export async function up(queryInterface: QueryInterface): Promise<void> {
  // Update any workflow requests with IN_PROGRESS status to PENDING
  await queryInterface.sequelize.query(`
    UPDATE workflow_requests 
    SET status = 'PENDING' 
    WHERE status = 'IN_PROGRESS';
  `);
  
  console.log('[Migration] Updated IN_PROGRESS workflow requests to PENDING');
}

export async function down(queryInterface: QueryInterface): Promise<void> {
  // Note: We cannot reliably restore IN_PROGRESS status since we don't know
  // which requests were originally IN_PROGRESS vs PENDING
  // This migration is one-way
  console.log('[Migration] Cannot rollback - IN_PROGRESS to PENDING migration is one-way');
}

