Skip to content

Commit

Permalink
Fix: Resolve issue with template association in Instance model
Browse files Browse the repository at this point in the history
The Issue:
The Instance model in the postgresql-schema.prisma file previously had a Template field that was a single Template object, but this caused issues with the association of multiple templates to a single instance.

The Change:
This commit resolves the issue by changing the Template field to an array of Template objects. This allows for multiple templates to be associated with a single instance.

The Impact:
This change allows for more flexible use of templates in the system and resolves a previous limitation in the association of templates to instances.

Affected Files:
- prisma/postgresql-schema.prisma
- src/api/services/template.service.ts

Note: The migration folder added in the untracked files section is a result of the Prisma schema change and can be safely ignored in this commit message.
  • Loading branch information
dgcode-tec committed Jul 12, 2024
1 parent 99a091e commit ca3dadf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- DropIndex
DROP INDEX "Template_instanceId_key";
4 changes: 2 additions & 2 deletions prisma/postgresql-schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ model Instance {
MessageUpdate MessageUpdate[]
TypebotSession TypebotSession[]
TypebotSetting TypebotSetting?
Template Template?
Template Template[]
}

model Session {
Expand Down Expand Up @@ -315,5 +315,5 @@ model Template {
createdAt DateTime? @default(now()) @db.Timestamp
updatedAt DateTime @updatedAt @db.Timestamp
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId String @unique
instanceId String
}
2 changes: 2 additions & 0 deletions src/api/services/template.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class TemplateService {
throw new Error('Error to create template');
}

console.log(response);

const template = await this.prismaRepository.template.create({
data: {
instanceId: getInstance.id,
Expand Down

0 comments on commit ca3dadf

Please sign in to comment.