task time
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTaskTimeTable1784100000000 implements MigrationInterface {
|
||||
name = "AddTaskTimeTable1784100000000";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "tm_times" (
|
||||
"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(),
|
||||
"startedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"endedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
"duration" integer NOT NULL,
|
||||
"adminId" uuid NOT NULL,
|
||||
"taskId" uuid NOT NULL,
|
||||
CONSTRAINT "PK_tm_times" PRIMARY KEY ("id")
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "tm_times"
|
||||
ADD CONSTRAINT "FK_tm_times_admin"
|
||||
FOREIGN KEY ("adminId") REFERENCES "user"("id")
|
||||
ON DELETE RESTRICT ON UPDATE NO ACTION
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "tm_times"
|
||||
ADD CONSTRAINT "FK_tm_times_task"
|
||||
FOREIGN KEY ("taskId") REFERENCES "tm_tasks"("id")
|
||||
ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "tm_times" DROP CONSTRAINT "FK_tm_times_task"`);
|
||||
await queryRunner.query(`ALTER TABLE "tm_times" DROP CONSTRAINT "FK_tm_times_admin"`);
|
||||
await queryRunner.query(`DROP TABLE "tm_times"`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user