import { QueryInterface } from 'sequelize';

/**
 * Migration: Update Request Number Format
 * 
 * This migration documents the change in request number format from:
 * - Old: REQ-YYYY-NNNNN (e.g., REQ-2025-12345)
 * - New: REQ-YYYY-MM-XXXX (e.g., REQ-2025-11-0001)
 * 
 * The counter now resets every month automatically.
 * 
 * No schema changes are required as the request_number column (VARCHAR(20))
 * is already sufficient for the new format (16 characters).
 * 
 * Existing request numbers will remain unchanged.
 * New requests will use the new format starting from this migration.
 */
export async function up(queryInterface: QueryInterface): Promise<void> {
  // No schema changes needed - this is a code-level change only
  // The generateRequestNumber() function in helpers.ts has been updated
  // to generate the new format: REQ-YYYY-MM-XXXX
  
  // Log the change for reference
  console.log('[Migration] Request number format updated to REQ-YYYY-MM-XXXX');
  console.log('[Migration] Counter will reset automatically each month');
}

export async function down(queryInterface: QueryInterface): Promise<void> {
  // No rollback needed - this is a code-level change
  // To revert, simply update the generateRequestNumber() function
  // in helpers.ts back to the old format
  console.log('[Migration] Request number format can be reverted by updating generateRequestNumber() function');
}

