import { MigrationInterface, QueryRunner } from 'typeorm';

/**
 * Cash collection for MD — the date picked on the form (client
 * 2026-10-21). It may be in the past, like a bill date; `created_at`
 * still records when the entry was made. Nullable, no backfill: older
 * entries keep showing their entry date.
 */
export class MdCashCollectionDate1788600000000 implements MigrationInterface {
  name = 'MdCashCollectionDate1788600000000';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "md_cash_collections" ADD COLUMN IF NOT EXISTS "collection_date" date`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "md_cash_collections" DROP COLUMN IF EXISTS "collection_date"`,
    );
  }
}
