feat: rename comment thread into activity (#939)
* feat: rename commentThread into activity server * feat: rename commentThread into activity front * feat: migration only create tables feat: migration only create tables * Update activities * fix: rebase partial fix * fix: all rebase problems and drop activity target alter * fix: lint * Update migration * Update migration * Fix conflicts * Fix conflicts --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
-- Create the new tables first, without any foreign key constraints
|
||||
-- Activities Table
|
||||
CREATE TABLE "activities" (
|
||||
"id" TEXT NOT NULL,
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `comment_thread_targets` table. If the table is not empty, all the data it contains will be lost.
|
||||
- You are about to drop the `comment_threads` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "attachments" DROP CONSTRAINT "attachments_activityId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "comment_thread_targets" DROP CONSTRAINT "comment_thread_targets_commentThreadId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "comment_thread_targets" DROP CONSTRAINT "comment_thread_targets_workspaceId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "comment_threads" DROP CONSTRAINT "comment_threads_assigneeId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "comment_threads" DROP CONSTRAINT "comment_threads_authorId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "comment_threads" DROP CONSTRAINT "comment_threads_workspaceId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "comments" DROP CONSTRAINT "comments_commentThreadId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "activity_targets" ADD COLUMN "commentableId" TEXT,
|
||||
ADD COLUMN "commentableType" "CommentableType",
|
||||
ALTER COLUMN "personId" DROP NOT NULL,
|
||||
ALTER COLUMN "companyId" DROP NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "comments" ADD COLUMN "activityId" TEXT;
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "comment_thread_targets";
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "comment_threads";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activities" ADD CONSTRAINT "activities_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activities" ADD CONSTRAINT "activities_assigneeId_fkey" FOREIGN KEY ("assigneeId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activities" ADD CONSTRAINT "activities_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "comments" ADD CONSTRAINT "comments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@ -20,20 +20,20 @@ generator nestgraphql {
|
||||
fields_Validator_from = "class-validator"
|
||||
|
||||
// All relations, only allow connect
|
||||
decorate_all_type = "!(CommentThreadTarget*Input|UserSettingsUpdateOneRequiredWithoutUserNestedInput)"
|
||||
decorate_all_type = "!(ActivityTarget*Input|UserSettingsUpdateOneRequiredWithoutUserNestedInput)"
|
||||
decorate_all_field = "*(create|connectOrCreate|update|upsert|delete|createMany|updateMany|deleteMany)"
|
||||
decorate_all_name = "HideField"
|
||||
decorate_all_from = "@nestjs/graphql"
|
||||
decorate_all_arguments = "[]"
|
||||
|
||||
// CommentThread: Only Allow targets createOrConnect / createMany
|
||||
decorate_commentThreadTargets_type = "*CommentThreadTarget*Input"
|
||||
decorate_commentThreadTargets_field = "*(update|upsert|updateMany)"
|
||||
decorate_commentThreadTargets_name = "HideField"
|
||||
decorate_commentThreadTargets_from = "@nestjs/graphql"
|
||||
decorate_commentThreadTargets_arguments = "[]"
|
||||
// Activity: Only Allow targets createOrConnect / createMany
|
||||
decorate_activityTargets_type = "*ActivityTarget*Input"
|
||||
decorate_activityTargets_field = "*(update|upsert|updateMany)"
|
||||
decorate_activityTargets_name = "HideField"
|
||||
decorate_activityTargets_from = "@nestjs/graphql"
|
||||
decorate_activityTargets_arguments = "[]"
|
||||
|
||||
// CommentThread: Only Allow targets createOrConnect / createMany
|
||||
// User Settings: Only Allow targets createOrConnect / createMany
|
||||
decorate_userSettings_type = "*UserSettingsUpdateOneRequiredWithoutUserNestedInput"
|
||||
decorate_userSettings_field = "!(update)"
|
||||
decorate_userSettings_name = "HideField"
|
||||
@ -106,10 +106,10 @@ model User {
|
||||
refreshTokens RefreshToken[]
|
||||
comments Comment[]
|
||||
|
||||
authoredCommentThreads CommentThread[] @relation(name: "authoredCommentThreads")
|
||||
assignedCommentThreads CommentThread[] @relation(name: "assignedCommentThreads")
|
||||
settings UserSettings @relation(fields: [settingsId], references: [id])
|
||||
settingsId String @unique
|
||||
authoredActivities Activity[] @relation(name: "authoredActivities")
|
||||
assignedActivities Activity[] @relation(name: "assignedActivities")
|
||||
settings UserSettings @relation(fields: [settingsId], references: [id])
|
||||
settingsId String @unique
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
@ -164,20 +164,20 @@ model Workspace {
|
||||
workspaceMember WorkspaceMember[]
|
||||
companies Company[]
|
||||
people Person[]
|
||||
commentThreads CommentThread[]
|
||||
activities Activity[]
|
||||
comments Comment[]
|
||||
pipelines Pipeline[]
|
||||
pipelineStages PipelineStage[]
|
||||
pipelineProgresses PipelineProgress[]
|
||||
activityTargets ActivityTarget[]
|
||||
viewFields ViewField[]
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
Attachment Attachment[]
|
||||
CommentThreadTarget CommentThreadTarget[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
Attachment Attachment[]
|
||||
|
||||
@@map("workspaces")
|
||||
}
|
||||
@ -234,8 +234,9 @@ model Company {
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
ActivityTarget ActivityTarget[]
|
||||
|
||||
@@map("companies")
|
||||
}
|
||||
@ -277,8 +278,9 @@ model Person {
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
ActivityTarget ActivityTarget[]
|
||||
|
||||
@@map("people")
|
||||
}
|
||||
@ -311,30 +313,28 @@ enum ActivityType {
|
||||
Task
|
||||
}
|
||||
|
||||
model CommentThread {
|
||||
model Activity {
|
||||
/// @Validator.IsString()
|
||||
/// @Validator.IsOptional()
|
||||
id String @id @default(uuid())
|
||||
|
||||
commentThreadTargets CommentThreadTarget[]
|
||||
comments Comment[]
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
authorId String
|
||||
author User @relation(fields: [authorId], references: [id], name: "authoredCommentThreads")
|
||||
|
||||
body String?
|
||||
title String?
|
||||
type ActivityType @default(Note)
|
||||
|
||||
id String @id @default(uuid())
|
||||
body String?
|
||||
title String?
|
||||
type ActivityType @default(Note)
|
||||
reminderAt DateTime?
|
||||
dueAt DateTime?
|
||||
completedAt DateTime?
|
||||
assignee User? @relation(fields: [assigneeId], references: [id], name: "assignedCommentThreads")
|
||||
assigneeId String?
|
||||
|
||||
activityTargets ActivityTarget[]
|
||||
comments Comment[]
|
||||
attachments Attachment[]
|
||||
author User @relation(fields: [authorId], references: [id], name: "authoredActivities")
|
||||
authorId String
|
||||
assignee User? @relation(fields: [assigneeId], references: [id], name: "assignedActivities")
|
||||
assigneeId String?
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
@ -342,9 +342,12 @@ model CommentThread {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
attachments Attachment[]
|
||||
@@map("activities")
|
||||
}
|
||||
|
||||
@@map("comment_threads")
|
||||
enum CommentableType {
|
||||
Person
|
||||
Company
|
||||
}
|
||||
|
||||
model Comment {
|
||||
@ -354,12 +357,13 @@ model Comment {
|
||||
/// @Validator.IsString()
|
||||
body String
|
||||
|
||||
author User @relation(fields: [authorId], references: [id])
|
||||
author User @relation(fields: [authorId], references: [id])
|
||||
authorId String
|
||||
commentThread CommentThread @relation(fields: [commentThreadId], references: [id], onDelete: Cascade)
|
||||
activity Activity? @relation(fields: [activityId], references: [id], onDelete: Cascade)
|
||||
activityId String?
|
||||
commentThreadId String
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
@ -372,24 +376,25 @@ model Comment {
|
||||
@@map("comments")
|
||||
}
|
||||
|
||||
enum CommentableType {
|
||||
Person
|
||||
Company
|
||||
}
|
||||
|
||||
model CommentThreadTarget {
|
||||
model ActivityTarget {
|
||||
/// @Validator.IsString()
|
||||
/// @Validator.IsOptional()
|
||||
id String @id @default(uuid())
|
||||
|
||||
commentThread CommentThread @relation(fields: [commentThreadId], references: [id], onDelete: Cascade)
|
||||
commentThreadId String
|
||||
/// @TypeGraphQL.omit(input: true, output: false)
|
||||
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
||||
activity Activity @relation(fields: [activityId], references: [id], onDelete: Cascade)
|
||||
activityId String
|
||||
commentableType CommentableType?
|
||||
commentableId String?
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String?
|
||||
commentableType CommentableType
|
||||
commentableId String
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
personId String?
|
||||
person Person? @relation(fields: [personId], references: [id])
|
||||
|
||||
companyId String?
|
||||
company Company? @relation(fields: [companyId], references: [id])
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
@ -397,7 +402,7 @@ model CommentThreadTarget {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("comment_thread_targets")
|
||||
@@map("activity_targets")
|
||||
}
|
||||
|
||||
model Pipeline {
|
||||
@ -515,17 +520,16 @@ model Attachment {
|
||||
type AttachmentType
|
||||
name String
|
||||
|
||||
authorId String
|
||||
author User @relation(fields: [authorId], references: [id], name: "authoredAttachments")
|
||||
|
||||
activityId String
|
||||
activity CommentThread @relation(fields: [activityId], references: [id])
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: false)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
workspaceId String
|
||||
|
||||
author User @relation(fields: [authorId], references: [id], name: "authoredAttachments")
|
||||
authorId String
|
||||
activity Activity @relation(fields: [activityId], references: [id])
|
||||
activityId String
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: false)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
export const seedComments = async (prisma: PrismaClient) => {
|
||||
await prisma.commentThread.upsert({
|
||||
await prisma.activity.upsert({
|
||||
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400' },
|
||||
update: {},
|
||||
create: {
|
||||
@ -13,15 +13,15 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.commentThreadTarget.upsert({
|
||||
await prisma.activityTarget.upsert({
|
||||
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb600' },
|
||||
update: {},
|
||||
create: {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb600',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
commentableType: 'Company',
|
||||
commentableId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
},
|
||||
});
|
||||
|
||||
@ -32,6 +32,7 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb200',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
body: 'Hi Félix ! How do you like your Twenty workspace?',
|
||||
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
authorId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
@ -44,12 +45,13 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b40-3ec3-4fe3-8997-b76aa0bfb200',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
body: 'I love it!',
|
||||
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
authorId: 'twenty-gk256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.commentThread.upsert({
|
||||
await prisma.activity.upsert({
|
||||
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408' },
|
||||
update: {},
|
||||
create: {
|
||||
@ -64,15 +66,15 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.commentThreadTarget.upsert({
|
||||
await prisma.activityTarget.upsert({
|
||||
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-a76aa0bfb600' },
|
||||
update: {},
|
||||
create: {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8997-a76aa0bfb600',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
commentableType: 'Person',
|
||||
commentableId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
|
||||
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
|
||||
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
},
|
||||
});
|
||||
|
||||
@ -83,12 +85,13 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb100',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
body: 'I really like this comment thread feature!',
|
||||
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
|
||||
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
|
||||
authorId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.commentThread.upsert({
|
||||
await prisma.activity.upsert({
|
||||
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408' },
|
||||
update: {},
|
||||
create: {
|
||||
@ -100,15 +103,15 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.commentThreadTarget.upsert({
|
||||
await prisma.activityTarget.upsert({
|
||||
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-a76aa0bfba00' },
|
||||
update: {},
|
||||
create: {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-a76aa0bfba00',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
commentableType: 'Company',
|
||||
commentableId: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e',
|
||||
commentThreadId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
|
||||
activityId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
},
|
||||
});
|
||||
|
||||
@ -119,6 +122,7 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aa0bfb000',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
body: 'I really like this comment thread feature!',
|
||||
activityId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
|
||||
commentThreadId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
|
||||
authorId: 'twenty-dev-gk256b39-3ec3-4fe3-8997-b76aa0boa408',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user