upgrade plan
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddPlanToInvoiceItem1767508304292 implements MigrationInterface {
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "invoice_item"
|
||||
ADD COLUMN "planId" uuid
|
||||
`);
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "invoice_item"
|
||||
ADD CONSTRAINT "FK_invoice_item_plan"
|
||||
FOREIGN KEY ("planId") REFERENCES "subscription_plan"("id")
|
||||
ON DELETE RESTRICT ON UPDATE NO ACTION
|
||||
`);
|
||||
|
||||
await queryRunner.query(`
|
||||
CREATE INDEX "IDX_invoice_item_plan" ON "invoice_item" ("planId")
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "invoice_item"
|
||||
DROP CONSTRAINT "FK_invoice_item_plan"
|
||||
`);
|
||||
|
||||
await queryRunner.query(`
|
||||
DROP INDEX "IDX_invoice_item_plan"
|
||||
`);
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "invoice_item"
|
||||
DROP COLUMN "planId"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user