feat: add workspace-type DTOs

This commit is contained in:
2026-06-30 12:31:22 +03:30
parent 9d8ff3603e
commit b0fba4bb84
3 changed files with 79 additions and 5 deletions
@@ -0,0 +1,66 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class TaskManager1782807558167 implements MigrationInterface {
name = 'TaskManager1782807558167'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "tm_workspace_types" ("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(), "name" character varying(100) NOT NULL, "description" text, "order" integer NOT NULL DEFAULT '0', CONSTRAINT "UQ_f6eb300d6dfa0f7dbfdf05e2592" UNIQUE ("name"), CONSTRAINT "PK_b3437ae89cc910f1f0ad3de0fc5" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_remarks" ("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(), "title" character varying(150) NOT NULL, "color" character varying(20), "taskId" uuid NOT NULL, CONSTRAINT "PK_99be294f0b23c3823d9ee784ebf" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TYPE "public"."tm_attachments_type_enum" AS ENUM('file', 'link', 'image', 'video')`);
await queryRunner.query(`CREATE TABLE "tm_attachments" ("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(), "title" character varying(150) NOT NULL, "type" "public"."tm_attachments_type_enum" NOT NULL, "file" text NOT NULL, "taskId" uuid NOT NULL, CONSTRAINT "PK_85eb42d47a75319a1ff074ff39c" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_check_list_items" ("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(), "title" character varying(150) NOT NULL, "isDone" boolean NOT NULL DEFAULT false, "taskId" uuid NOT NULL, CONSTRAINT "PK_0bb2fee42ccb8a7f4c5c054ea71" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_tasks" ("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(), "title" character varying(150) NOT NULL, "description" text, "color" character varying(20), "startDate" TIMESTAMP WITH TIME ZONE, "endDate" TIMESTAMP WITH TIME ZONE, "taskPhaseId" uuid NOT NULL, CONSTRAINT "PK_f975c1e9cc0cfc054482cb36028" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_task_phases" ("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(), "name" character varying(100) NOT NULL, "order" integer NOT NULL DEFAULT '0', "color" character varying(20), "projectId" uuid NOT NULL, CONSTRAINT "PK_045ad1778b77407b8e4017cc9b2" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_projects" ("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(), "name" character varying(150) NOT NULL, "ownerName" character varying(150), "description" text, "startDate" TIMESTAMP WITH TIME ZONE, "workspaceId" uuid NOT NULL, CONSTRAINT "PK_0ceacba52c6bb5cec6481b910e4" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_workspaces" ("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(), "name" character varying(100) NOT NULL, "description" text, "color" character varying(20) NOT NULL, "isActive" boolean NOT NULL DEFAULT true, "workspaceTypeId" uuid NOT NULL, CONSTRAINT "PK_fb4be955b5b4b11aacc5169e9d5" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE TABLE "tm_task_users" ("taskId" uuid NOT NULL, "userId" uuid NOT NULL, CONSTRAINT "PK_bb8f94f4ea4715ad190bc4fb23c" PRIMARY KEY ("taskId", "userId"))`);
await queryRunner.query(`CREATE INDEX "IDX_739cfd1807f78bb2ebda02e7bc" ON "tm_task_users" ("taskId") `);
await queryRunner.query(`CREATE INDEX "IDX_3fe44ce1acd8a620affb55a750" ON "tm_task_users" ("userId") `);
await queryRunner.query(`CREATE TABLE "tm_workspace_users" ("workspaceId" uuid NOT NULL, "userId" uuid NOT NULL, CONSTRAINT "PK_7f8b37c58e5267bc16cf577fcbd" PRIMARY KEY ("workspaceId", "userId"))`);
await queryRunner.query(`CREATE INDEX "IDX_ca9b0a16dfec7c4753ea4910f0" ON "tm_workspace_users" ("workspaceId") `);
await queryRunner.query(`CREATE INDEX "IDX_1c9d677417216377d55a060011" ON "tm_workspace_users" ("userId") `);
await queryRunner.query(`ALTER TABLE "reward_withdraw_request" ADD CONSTRAINT "UQ_79526c10ecb097f553e0120a36e" UNIQUE ("transactionId")`);
await queryRunner.query(`ALTER TABLE "tm_remarks" ADD CONSTRAINT "FK_bc03cabb99c42245436fcbb4e6a" FOREIGN KEY ("taskId") REFERENCES "tm_tasks"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_attachments" ADD CONSTRAINT "FK_1e9ab0f9ec5b898abea95d21fb2" FOREIGN KEY ("taskId") REFERENCES "tm_tasks"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_check_list_items" ADD CONSTRAINT "FK_14730b0971bcdc5547889392606" FOREIGN KEY ("taskId") REFERENCES "tm_tasks"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_tasks" ADD CONSTRAINT "FK_f7462cec045e564d5fd54d17177" FOREIGN KEY ("taskPhaseId") REFERENCES "tm_task_phases"("id") ON DELETE RESTRICT ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_task_phases" ADD CONSTRAINT "FK_884b8c2fe724031aa61c8181f0b" FOREIGN KEY ("projectId") REFERENCES "tm_projects"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_projects" ADD CONSTRAINT "FK_c3d997618910273be84d58faa8c" FOREIGN KEY ("workspaceId") REFERENCES "tm_workspaces"("id") ON DELETE RESTRICT ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_workspaces" ADD CONSTRAINT "FK_253e36f065cfc1eca58abaefb22" FOREIGN KEY ("workspaceTypeId") REFERENCES "tm_workspace_types"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_task_users" ADD CONSTRAINT "FK_739cfd1807f78bb2ebda02e7bce" FOREIGN KEY ("taskId") REFERENCES "tm_tasks"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
await queryRunner.query(`ALTER TABLE "tm_task_users" ADD CONSTRAINT "FK_3fe44ce1acd8a620affb55a7500" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "tm_workspace_users" ADD CONSTRAINT "FK_ca9b0a16dfec7c4753ea4910f00" FOREIGN KEY ("workspaceId") REFERENCES "tm_workspaces"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
await queryRunner.query(`ALTER TABLE "tm_workspace_users" ADD CONSTRAINT "FK_1c9d677417216377d55a060011d" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "tm_workspace_users" DROP CONSTRAINT "FK_1c9d677417216377d55a060011d"`);
await queryRunner.query(`ALTER TABLE "tm_workspace_users" DROP CONSTRAINT "FK_ca9b0a16dfec7c4753ea4910f00"`);
await queryRunner.query(`ALTER TABLE "tm_task_users" DROP CONSTRAINT "FK_3fe44ce1acd8a620affb55a7500"`);
await queryRunner.query(`ALTER TABLE "tm_task_users" DROP CONSTRAINT "FK_739cfd1807f78bb2ebda02e7bce"`);
await queryRunner.query(`ALTER TABLE "tm_workspaces" DROP CONSTRAINT "FK_253e36f065cfc1eca58abaefb22"`);
await queryRunner.query(`ALTER TABLE "tm_projects" DROP CONSTRAINT "FK_c3d997618910273be84d58faa8c"`);
await queryRunner.query(`ALTER TABLE "tm_task_phases" DROP CONSTRAINT "FK_884b8c2fe724031aa61c8181f0b"`);
await queryRunner.query(`ALTER TABLE "tm_tasks" DROP CONSTRAINT "FK_f7462cec045e564d5fd54d17177"`);
await queryRunner.query(`ALTER TABLE "tm_check_list_items" DROP CONSTRAINT "FK_14730b0971bcdc5547889392606"`);
await queryRunner.query(`ALTER TABLE "tm_attachments" DROP CONSTRAINT "FK_1e9ab0f9ec5b898abea95d21fb2"`);
await queryRunner.query(`ALTER TABLE "tm_remarks" DROP CONSTRAINT "FK_bc03cabb99c42245436fcbb4e6a"`);
await queryRunner.query(`ALTER TABLE "reward_withdraw_request" DROP CONSTRAINT "UQ_79526c10ecb097f553e0120a36e"`);
await queryRunner.query(`DROP INDEX "public"."IDX_1c9d677417216377d55a060011"`);
await queryRunner.query(`DROP INDEX "public"."IDX_ca9b0a16dfec7c4753ea4910f0"`);
await queryRunner.query(`DROP TABLE "tm_workspace_users"`);
await queryRunner.query(`DROP INDEX "public"."IDX_3fe44ce1acd8a620affb55a750"`);
await queryRunner.query(`DROP INDEX "public"."IDX_739cfd1807f78bb2ebda02e7bc"`);
await queryRunner.query(`DROP TABLE "tm_task_users"`);
await queryRunner.query(`DROP TABLE "tm_workspaces"`);
await queryRunner.query(`DROP TABLE "tm_projects"`);
await queryRunner.query(`DROP TABLE "tm_task_phases"`);
await queryRunner.query(`DROP TABLE "tm_tasks"`);
await queryRunner.query(`DROP TABLE "tm_check_list_items"`);
await queryRunner.query(`DROP TABLE "tm_attachments"`);
await queryRunner.query(`DROP TYPE "public"."tm_attachments_type_enum"`);
await queryRunner.query(`DROP TABLE "tm_remarks"`);
await queryRunner.query(`DROP TABLE "tm_workspace_types"`);
}
}