Skip to content

Fixed boolean and integer type attributes for MySQL #1786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025

Conversation

bilaliqbalr
Copy link

@bilaliqbalr bilaliqbalr commented Jul 31, 2025

🐞 Describe the bug

When running the container and executing Prisma commands for MySQL, Prisma throws schema validation errors due to incorrect native type usage in mysql-schema.prisma. The current schema uses PostgreSQL-native types (@db.Integer, @db.Boolean, etc.), which are not valid for MySQL.


🧪 Steps to reproduce

  1. Pull the latest Evolution API Docker image (2.3.1)
  2. Ensure .env is correctly set for a MySQL database
  3. Run:

Which version of the API are you using?

latest

What is your environment?

Linux

Other environment specifications

No response

If applicable, paste the log output

Prisma schema loaded from prisma/mysql-schema.prisma
Error: Prisma schema validation - (get-dmmf wasm)
Error code: P1012
error: Native type Boolean is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:650
   | 
649 |   id              String           @id @default(cuid())
650 |   enabled         Boolean          @default(true) @db.Boolean
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:657
   | 
656 |   keywordFinish   String?          @db.VarChar(100)
657 |   delayMessage    Int?             @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:662
   | 
661 |   keepOpen        Boolean?         @default(false)
662 |   debounceTime    Int?             @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:665
   | 
664 |   splitMessages   Boolean?         @default(false)
665 |   timePerChar     Int?             @default(50) @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:680
   | 
679 |   keywordFinish   String?   @db.VarChar(100)
680 |   delayMessage    Int?      @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:685
   | 
684 |   keepOpen        Boolean?  @default(false)
685 |   debounceTime    Int?      @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:688
   | 
687 |   splitMessages   Boolean?  @default(false)
688 |   timePerChar     Int?      @default(50) @db.Integer
   | 
error: Native type Boolean is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:699
   | 
698 |   id              String           @id @default(cuid())
699 |   enabled         Boolean          @default(true) @db.Boolean
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:705
   | 
704 |   keywordFinish   String?          @db.VarChar(100)
705 |   delayMessage    Int?             @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:710
   | 
709 |   keepOpen        Boolean?         @default(false)
710 |   debounceTime    Int?             @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:713
   | 
712 |   splitMessages   Boolean?         @default(false)
713 |   timePerChar     Int?             @default(50) @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:728
   | 
727 |   keywordFinish   String?   @db.VarChar(100)
728 |   delayMessage    Int?      @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:733
   | 
732 |   keepOpen        Boolean?  @default(false)
733 |   debounceTime    Int?      @db.Integer
   | 
error: Native type Integer is not supported for mysql connector.
  -->  prisma/mysql-schema.prisma:736
   | 
735 |   splitMessages   Boolean?  @default(false)
736 |   timePerChar     Int?      @default(50) @db.Integer
   | 
error: Error validating field `Instance` in model `N8nSetting`: The relation field `Instance` on model `N8nSetting` is missing an opposite relation field on the model `Instance`. Either run `prisma format` or add it manually.
  -->  prisma/mysql-schema.prisma:693
   | 
692 |   n8nIdFallback   String?   @db.VarChar(100)
693 |   Instance        Instance  @relation(fields: [instanceId], references: [id], onDelete: Cascade)
694 |   instanceId      String    @unique
   | 
error: Error validating field `Instance` in model `Evoai`: The relation field `Instance` on model `Evoai` is missing an opposite relation field on the model `Instance`. Either run `prisma format` or add it manually.
  -->  prisma/mysql-schema.prisma:719
   | 
718 |   updatedAt       DateTime         @updatedAt @db.Timestamp
719 |   Instance        Instance         @relation(fields: [instanceId], references: [id], onDelete: Cascade)
720 |   instanceId      String
   | 
error: Error validating field `Instance` in model `EvoaiSetting`: The relation field `Instance` on model `EvoaiSetting` is missing an opposite relation field on the model `Instance`. Either run `prisma format` or add it manually.
  -->  prisma/mysql-schema.prisma:741
   | 
740 |   evoaiIdFallback String?   @db.VarChar(100)
741 |   Instance        Instance  @relation(fields: [instanceId], references: [id], onDelete: Cascade)
742 |   instanceId      String    @unique
   | 

Validation Error Count: 17
[Context: getDmmf]

Prisma CLI Version : 6.11.1
Error executing command: npx prisma generate --schema ./prisma/mysql-schema.prisma
Prisma generate failed

Summary by Sourcery

Fix Prisma schema validation errors for MySQL by correcting unsupported native type annotations on Boolean and Int fields and restoring missing inverse relations on the Instance model.

Bug Fixes:

  • Remove unsupported @db.Boolean annotations from Boolean fields in the MySQL Prisma schema
  • Remove unsupported @db.Integer annotations from Int fields in the MySQL Prisma schema
  • Add missing opposite relation fields for Instance on N8nSetting, Evoai, and EvoaiSetting models

Copy link
Contributor

sourcery-ai bot commented Jul 31, 2025

Reviewer's Guide

This PR fixes schema validation errors by replacing unsupported PostgreSQL native type annotations in the MySQL Prisma schema with correct MySQL types or defaults, and adds the missing opposite relation fields on the Instance model to complete bidirectional relations.

File-Level Changes

Change Details Files
Correct native type annotations for boolean fields
  • Removed all @db.Boolean annotations
  • Replaced unsupported boolean native types with @db.TinyInt(1) or default mapping
prisma/mysql-schema.prisma
Correct native type annotations for integer fields
  • Removed all @db.Integer annotations
  • Replaced unsupported integer native types with default Int mapping
prisma/mysql-schema.prisma
Add missing inverse relation fields on Instance model
  • Defined relation fields for N8nSetting, Evoai, and EvoaiSetting on Instance
  • Ensured each relation uses @relation with correct reference and onDelete behavior
prisma/mysql-schema.prisma

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bilaliqbalr - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@DavidsonGomes DavidsonGomes changed the base branch from main to develop August 4, 2025 21:51
@DavidsonGomes DavidsonGomes merged commit dab66fc into EvolutionAPI:develop Aug 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants