import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddBookingParentToTransaction1749604239749
  implements MigrationInterface
{
  name = 'AddBookingParentToTransaction1749604239749';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`ALTER TABLE "transactions" ADD "parent_id" uuid`);

    await queryRunner.query(
      `ALTER TABLE "transactions" ADD CONSTRAINT "FK_413e95171729ba18cabce1c31e3" FOREIGN KEY ("parent_id") REFERENCES "transactions"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP CONSTRAINT "FK_413e95171729ba18cabce1c31e3"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transactions" DROP COLUMN "parent_id"`,
    );
  }
}
