Files
dsc-api/database/migrations/1785000000000-addTicketMasterEntity.ts
T
2026-07-26 08:44:56 +03:30

20 lines
1.0 KiB
TypeScript

import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTicketMasterEntity1785000000000 implements MigrationInterface {
name = "AddTicketMasterEntity1785000000000";
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "ticket_master" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "userId" uuid NOT NULL, CONSTRAINT "UQ_ticket_master_user" UNIQUE ("userId"), CONSTRAINT "PK_ticket_master" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`ALTER TABLE "ticket_master" ADD CONSTRAINT "FK_ticket_master_user" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "ticket_master" DROP CONSTRAINT "FK_ticket_master_user"`);
await queryRunner.query(`DROP TABLE "ticket_master"`);
}
}