/**
 * CLUB-004 — Club recovery codes: add index on code_fingerprint.
 *
 * The consumeRecoveryCode() flow looks up by fingerprint, which must be fast.
 *
 * @param {import('node-pg-migrate').MigrationBuilder} pgm
 */
export const up = (pgm) => {
  pgm.sql(`
    CREATE INDEX IF NOT EXISTS club_recovery_codes_code_fingerprint_idx
      ON club_recovery_codes (code_fingerprint)
      WHERE used_at IS NULL
  `);
};

/** @param {import('node-pg-migrate').MigrationBuilder} pgm */
export const down = (pgm) => {
  pgm.sql('DROP INDEX IF EXISTS club_recovery_codes_code_fingerprint_idx');
};
