50 lines
2.5 KiB
TypeScript
50 lines
2.5 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
export class AddTaxItemTransaction1726045820711 implements MigrationInterface {
|
|
name = 'AddTaxItemTransaction1726045820711';
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`CREATE TABLE "transaction_item_taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "tax_id" character varying, "tax_name" character varying, "taxt_value" numeric, "tax_total_value" numeric, "transaction_id" uuid, CONSTRAINT "PK_fc5f6da61b24eb5bfdd503b0a0d" PRIMARY KEY ("id"))`,
|
|
);
|
|
await queryRunner.query(
|
|
`CREATE TABLE "t_breakdown_item_taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "tax_id" character varying, "tax_name" character varying, "taxt_value" numeric, "tax_total_value" numeric, "transaction_id" uuid, CONSTRAINT "PK_a1ef08d2c68169a50102aa70eca" PRIMARY KEY ("id"))`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "transaction_items" ADD "total_profit_share" numeric`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "transaction_item_breakdowns" ADD "total_profit_share" numeric`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "price_formulas" ADD "value_for" character varying NOT NULL DEFAULT 'dpp'`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "transaction_item_taxes" ADD CONSTRAINT "FK_f5c4966a381d903899cafb4b5ba" FOREIGN KEY ("transaction_id") REFERENCES "transaction_items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "t_breakdown_item_taxes" ADD CONSTRAINT "FK_74bedce7e94f6707ddf26ef0c0f" FOREIGN KEY ("transaction_id") REFERENCES "transaction_item_breakdowns"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(
|
|
`ALTER TABLE "t_breakdown_item_taxes" DROP CONSTRAINT "FK_74bedce7e94f6707ddf26ef0c0f"`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "transaction_item_taxes" DROP CONSTRAINT "FK_f5c4966a381d903899cafb4b5ba"`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "price_formulas" DROP COLUMN "value_for"`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_profit_share"`,
|
|
);
|
|
await queryRunner.query(
|
|
`ALTER TABLE "transaction_items" DROP COLUMN "total_profit_share"`,
|
|
);
|
|
await queryRunner.query(`DROP TABLE "t_breakdown_item_taxes"`);
|
|
await queryRunner.query(`DROP TABLE "transaction_item_taxes"`);
|
|
}
|
|
}
|