import type { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Per-tenant booking-number prefix. Printed before the 6-digit number
 * (e.g. `MT` → `MT-093254`). Null/empty falls back to `BK` at
 * allocation time, so existing tenants keep `BK-` with no backfill.
 * Queries are unaffected — they always use the fixed `QRY-` prefix.
 */
export class TenantSettingsBookingPrefix1787500000000 implements MigrationInterface {
  name = 'TenantSettingsBookingPrefix1787500000000';

  public async up(qr: QueryRunner): Promise<void> {
    await qr.query(`
      ALTER TABLE "tenant_settings"
        ADD COLUMN IF NOT EXISTS "booking_prefix" varchar(10) NULL
    `);
  }

  public async down(qr: QueryRunner): Promise<void> {
    await qr.query(`
      ALTER TABLE "tenant_settings"
        DROP COLUMN IF EXISTS "booking_prefix"
    `);
  }
}
