From c7823054565da64acfc4f30c053c8e9ef1ab2b8a Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Fri, 12 Jul 2024 13:25:59 -0300 Subject: [PATCH] Remove template model and related functionality (prisma/postgresql-schema.prisma, src/api/services/template.service.ts) This commit removes the Template model, including its related functionality, from the project. The template table has been removed from the database schema, and all related functions and methods in the template service have been deleted. This change was made because the project now uses the persistence of the meta, eliminating the need for a separate template model. Please note that this change may affect other parts of the application that rely on the Template model. Ensure that all necessary adjustments have been made before merging this commit. --- .../migration.sql | 11 +++++++++ prisma/postgresql-schema.prisma | 12 ---------- src/api/services/template.service.ts | 23 ++++--------------- 3 files changed, 15 insertions(+), 31 deletions(-) create mode 100644 prisma/migrations/20240712162206_remove_templates_table/migration.sql diff --git a/prisma/migrations/20240712162206_remove_templates_table/migration.sql b/prisma/migrations/20240712162206_remove_templates_table/migration.sql new file mode 100644 index 000000000..3da4351a9 --- /dev/null +++ b/prisma/migrations/20240712162206_remove_templates_table/migration.sql @@ -0,0 +1,11 @@ +/* + Warnings: + + - You are about to drop the `Template` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "Template" DROP CONSTRAINT "Template_instanceId_fkey"; + +-- DropTable +DROP TABLE "Template"; diff --git a/prisma/postgresql-schema.prisma b/prisma/postgresql-schema.prisma index 6c0ee0d4d..fdb73b246 100644 --- a/prisma/postgresql-schema.prisma +++ b/prisma/postgresql-schema.prisma @@ -75,7 +75,6 @@ model Instance { MessageUpdate MessageUpdate[] TypebotSession TypebotSession[] TypebotSetting TypebotSetting? - Template Template[] } model Session { @@ -306,14 +305,3 @@ model TypebotSetting { Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) instanceId String @unique } - -model Template { - id String @id @default(cuid()) - name String @db.VarChar(255) - language String @db.VarChar(255) - templateId String @unique @db.VarChar(255) - createdAt DateTime? @default(now()) @db.Timestamp - updatedAt DateTime @updatedAt @db.Timestamp - Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) - instanceId String -} diff --git a/src/api/services/template.service.ts b/src/api/services/template.service.ts index d00aec47a..2fd88a9e5 100644 --- a/src/api/services/template.service.ts +++ b/src/api/services/template.service.ts @@ -1,4 +1,3 @@ -import { Template } from '@prisma/client'; import axios from 'axios'; import { ConfigService, WaBusiness } from '../../config/env.config'; @@ -39,7 +38,7 @@ export class TemplateService { return response.data; } - public async create(instance: InstanceDto, data: TemplateDto): Promise