import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transaction_items" ADD "subtotal" numeric`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" ADD "discount_value" numeric`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_item_breakdowns" ADD "subtotal" numeric`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_item_breakdowns" ADD "discount_value" numeric`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_item_breakdowns" ADD "total_price" numeric`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_price"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "discount_value"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "subtotal"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" DROP COLUMN "discount_value"`,
    );
    await queryRunner.query(
      `ALTER TABLE "transaction_items" DROP COLUMN "subtotal"`,
    );
  }
}
