MismatchedTokenException when migrating from neon/docker to prisma postgres

For some reason im getting a schema parsing error when moving from docker (locally) + neon to prisma postgres. I started with bunx prisma dev to spin up a local dev database. After running prisma generate + prisma migrate, I'm getting the following error MismatchedTokenException: Expecting --> '{' <-- but found --> 'non-linear' <-- I'm not sure why switching db providers would cause the schema to be invalid
11 Replies
Prisma AI Help
Prisma AI Help2mo ago
You've gone full bot mode! Let me fetch that AI answer for you ASAP. The error you're seeing, MismatchedTokenException: Expecting --> '{' <-- but found --> 'non-linear' <--, typically points to a syntax issue in your Prisma schema file, not a direct problem with switching database providers. However, switching providers (e.g., from Neon/docker to a local Postgres instance) can surface schema or migration issues that were previously hidden or ignored. A few key points from the knowledge sources: - When switching database providers, you cannot reuse migration files generated for a different provider (e.g., SQLite or Neon) because they may contain provider-specific SQL. This can cause migration or schema parsing errors. The recommended approach is to delete old migration files and generate new ones for the new provider. This is confirmed in several issues, where users resolved similar errors by deleting prior migrations and starting fresh with the new provider's migrations Syntax error when migrating to postgres via a docker-compose container db push error after migrating from Planetscale to Neon. - Prisma's migration engine expects the schema and migration files to match the current provider. If you have migration files with SQL or schema definitions incompatible with your new provider, parsing errors like the one you see can occur. - The error message itself suggests a typo or invalid block in your schema.prisma file. Double-check for any misplaced or misspelled keywords, especially around model or enum definitions. What to do: 1. Delete your existing migration files (especially if they were created for a different provider). 2. Double-check your schema.prisma for syntax errors—look for any unexpected words or misplaced braces. 3. Run prisma migrate dev again to generate fresh migrations for your current provider. If you still encounter issues, please share the relevant part of your schema.prisma file where the error occurs, as the knowledge sources do not provide details on the specific "non-linear" token. In summary: Switching providers requires fresh migrations and a valid schema. Old migrations or schema typos are the most common cause of this error when changing providers Syntax error when migrating to postgres via a docker-compose container. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
ryanisaboi1
ryanisaboi1OP2mo ago
I already re-generated my migration files here it is
Nurul
Nurul2mo ago
Hey! The error you are facing seems to be related to enums: I'm getting the following error MismatchedTokenException: Expecting --> '{' <-- but found --> 'non-linear' <-- You have an enum NONLINEAR, was it defined as NON-LINEAR or something else before? You get this error as soon as you run npx prisma migrate command?
ryanisaboi1
ryanisaboi1OP2mo ago
Nope im able to run migrate perfectlly fine, an view the db via other programs like Postico, but using prisma studio and trying to do a db query with prisma client causes this to break
Nurul
Nurul2mo ago
Ah, okay! Would it be possible for you to provide a minimal reproduction so that I can share it with team internally?
ryanisaboi1
ryanisaboi1OP2mo ago
sorry about that. here is the repo https://github.com/ryanyue123/prisma-postgres-error to reproduce, i created a dev db using bux prisma dev and added that DATABASE_URL to the .env in server/ for example:
DATABASE_URL="prisma+postgres://localhost:51213/?api_key=eyJkYXRhYmFzZVVybCI6InBvc3RncmVzOi8vcG9zdGdyZXM6cG9zdGdyZXNAbG9jYWxob3N0OjUxMjE0L3RlbXBsYXRlMT9zc2xtb2RlPWRpc2FibGUmY29ubmVjdGlvbl9saW1pdD0xJmNvbm5lY3RfdGltZW91dD0wJm1heF9pZGxlX2Nvbm5lY3Rpb25fbGlmZXRpbWU9MCZwb29sX3RpbWVvdXQ9MCZzaW5nbGVfdXNlX2Nvbm5lY3Rpb25zPXRydWUmc29ja2V0X3RpbWVvdXQ9MCIsIm5hbWUiOiJkZWZhdWx0Iiwic2hhZG93RGF0YWJhc2VVcmwiOiJwb3N0Z3JlczovL3Bvc3RncmVzOnBvc3RncmVzQGxvY2FsaG9zdDo1MTIxNS90ZW1wbGF0ZTE_c3NsbW9kZT1kaXNhYmxlJmNvbm5lY3Rpb25fbGltaXQ9MSZjb25uZWN0X3RpbWVvdXQ9MCZtYXhfaWRsZV9jb25uZWN0aW9uX2xpZmV0aW1lPTAmcG9vbF90aW1lb3V0PTAmc2luZ2xlX3VzZV9jb25uZWN0aW9ucz10cnVlJnNvY2tldF90aW1lb3V0PTAifQ"
DATABASE_URL="prisma+postgres://localhost:51213/?api_key=eyJkYXRhYmFzZVVybCI6InBvc3RncmVzOi8vcG9zdGdyZXM6cG9zdGdyZXNAbG9jYWxob3N0OjUxMjE0L3RlbXBsYXRlMT9zc2xtb2RlPWRpc2FibGUmY29ubmVjdGlvbl9saW1pdD0xJmNvbm5lY3RfdGltZW91dD0wJm1heF9pZGxlX2Nvbm5lY3Rpb25fbGlmZXRpbWU9MCZwb29sX3RpbWVvdXQ9MCZzaW5nbGVfdXNlX2Nvbm5lY3Rpb25zPXRydWUmc29ja2V0X3RpbWVvdXQ9MCIsIm5hbWUiOiJkZWZhdWx0Iiwic2hhZG93RGF0YWJhc2VVcmwiOiJwb3N0Z3JlczovL3Bvc3RncmVzOnBvc3RncmVzQGxvY2FsaG9zdDo1MTIxNS90ZW1wbGF0ZTE_c3NsbW9kZT1kaXNhYmxlJmNvbm5lY3Rpb25fbGltaXQ9MSZjb25uZWN0X3RpbWVvdXQ9MCZtYXhfaWRsZV9jb25uZWN0aW9uX2xpZmV0aW1lPTAmcG9vbF90aW1lb3V0PTAmc2luZ2xlX3VzZV9jb25uZWN0aW9ucz10cnVlJnNvY2tldF90aW1lb3V0PTAifQ"
then i ran bun db:studio and was able to see the error
GitHub
GitHub - ryanyue123/prisma-postgres-error
Contribute to ryanyue123/prisma-postgres-error development by creating an account on GitHub.
ryanisaboi1
ryanisaboi1OP4w ago
hi @Nurul (Prisma) sorry to bother you. any feedback on this? hey just wanted to bump this here. @Nurul (Prisma) or if anyone else could help!
Nurul
Nurul4w ago
Hey, thanks! Sorry for the delay in getting back. I'll try reproducing this today
Nurul
Nurul4w ago
I followed the instructions and I got the Studio UI. Were you able to reach this UI or were getting the error even before seeing this UI?
No description
ryanisaboi1
ryanisaboi1OP4w ago
I was not able to reach this UI, i would get the error. im using bun - maybe it's something wrong with my local machine?
Nurul
Nurul4w ago
Would be interesting to see if you run into the same issue on other device

Did you find this page helpful?