Scheduling infrastructure for absolutely everyone.
chore: drop sourceLang, targetLang and id columns (#17792)
Benny Joo2a578ea9d538
diff --git a/packages/features/tasker/tasks/translateEventTypeDescription.ts b/packages/features/tasker/tasks/translateEventTypeDescription.tsindex e1c4a492200..900d1d437e0 100644--- a/packages/features/tasker/tasks/translateEventTypeDescription.ts+++ b/packages/features/tasker/tasks/translateEventTypeDescription.ts@@ -63,9 +63,6 @@ export async function translateEventTypeDescription(payload: string): Promise<voeventTypeId,sourceLocale: userLocale,targetLocale,- // Keep old fields during transition- sourceLang: userLocale, // TODO: remove after migration- targetLang: targetLocale, // TODO: remove after migrationtranslatedText,userId,}))diff --git a/packages/lib/server/repository/eventTypeTranslation.ts b/packages/lib/server/repository/eventTypeTranslation.tsindex fac72c4faaa..c619bda00b4 100644--- a/packages/lib/server/repository/eventTypeTranslation.ts+++ b/packages/lib/server/repository/eventTypeTranslation.ts@@ -4,7 +4,6 @@ import { EventTypeAutoTranslatedField } from "@calcom/prisma/enums";export type CreateEventTypeDescriptionTranslation = Omit<EventTypeTranslation,- | "id" // TODO: remove after migration| "uid"| "createdAt"| "createdBy"@@ -20,23 +19,14 @@ export class EventTypeTranslationRepository {static async upsertManyDescriptionTranslations(translations: Array<CreateEventTypeDescriptionTranslation>) {return await Promise.all(translations.map(({ userId, ...translation }) => {- const whereClause = translation.targetLang // TODO: remove after migration- ? {- eventTypeId_field_targetLang: {- eventTypeId: translation.eventTypeId,- field: EventTypeAutoTranslatedField.DESCRIPTION,- targetLang: translation.targetLang,- },- }- : {- eventTypeId_field_targetLocale: {- eventTypeId: translation.eventTypeId,- field: EventTypeAutoTranslatedField.DESCRIPTION,- targetLocale: translation.targetLocale,- },- };return prisma.eventTypeTranslation.upsert({- where: whereClause,+ where: {+ eventTypeId_field_targetLocale: {+ eventTypeId: translation.eventTypeId,+ field: EventTypeAutoTranslatedField.DESCRIPTION,+ targetLocale: translation.targetLocale,+ },+ },update: {translatedText: translation.translatedText,updatedBy: userId,diff --git a/packages/prisma/migrations/20241127102756_remove_fields_from_evenet_type_translation/migration.sql b/packages/prisma/migrations/20241127102756_remove_fields_from_evenet_type_translation/migration.sqlnew file mode 100644index 00000000000..28efa8e7f05--- /dev/null+++ b/packages/prisma/migrations/20241127102756_remove_fields_from_evenet_type_translation/migration.sql@@ -0,0 +1,28 @@+/*+ Warnings:++ - The primary key for the `EventTypeTranslation` table will be changed. If it partially fails, the table could be left without primary key constraint.+ - You are about to drop the column `id` on the `EventTypeTranslation` table. All the data in the column will be lost.+ - You are about to drop the column `sourceLang` on the `EventTypeTranslation` table. All the data in the column will be lost.+ - You are about to drop the column `targetLang` on the `EventTypeTranslation` table. All the data in the column will be lost.+ - Made the column `uid` on table `EventTypeTranslation` required. This step will fail if there are existing NULL values in that column.++*/++-- Copy data+UPDATE "EventTypeTranslation" SET+ "uid" = "id";++-- DropIndex+DROP INDEX "EventTypeTranslation_eventTypeId_field_targetLang_idx";++-- DropIndex+DROP INDEX "EventTypeTranslation_eventTypeId_field_targetLang_key";++-- AlterTable+ALTER TABLE "EventTypeTranslation" DROP CONSTRAINT "EventTypeTranslation_pkey",+DROP COLUMN "id",+DROP COLUMN "sourceLang",+DROP COLUMN "targetLang",+ALTER COLUMN "uid" SET NOT NULL,+ADD CONSTRAINT "EventTypeTranslation_pkey" PRIMARY KEY ("uid");diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prismaindex 270d9e35ae5..d2596c05dd3 100644--- a/packages/prisma/schema.prisma+++ b/packages/prisma/schema.prisma@@ -1639,13 +1639,10 @@ enum EventTypeAutoTranslatedField {}model EventTypeTranslation {- id String @id @default(cuid())- uid String?+ uid String @id @default(cuid())eventType EventType @relation(fields: [eventTypeId], references: [id], onDelete: Cascade)eventTypeId Intfield EventTypeAutoTranslatedField- sourceLang String- targetLang StringsourceLocale StringtargetLocale StringtranslatedText String @db.Text@@ -1656,9 +1653,7 @@ model EventTypeTranslation {creator User @relation("CreatedEventTypeTranslations", fields: [createdBy], references: [id])updater User? @relation("UpdatedEventTypeTranslations", fields: [updatedBy], references: [id], onDelete: SetNull)- @@unique([eventTypeId, field, targetLang]) // TODO: remove after migration@@unique([eventTypeId, field, targetLocale])- @@index([eventTypeId, field, targetLang]) // TODO: remove after migration@@index([eventTypeId, field, targetLocale])}