P
Prisma•3w ago
guizin

Prisma does not recognize Json type even after migrate/generate

Already ran prisma generate and migrate, in my database (postgres) it recognizes descriptor column as Json
No description
No description
4 Replies
Prisma AI Help
Prisma AI Help•3w ago
Skipping coffee for instant knowledge! Let's brew that AI answer now. If Prisma does not recognize your descriptor column as Json in your PostgreSQL database even after running prisma migrate and prisma generate, there are a few common causes and solutions: 1. Column Type in Database: Prisma will only recognize a column as Json if its type in PostgreSQL is actually json or jsonb. If the column is still of type TEXT (possibly from a previous Prisma 1 setup), Prisma will map it as String instead of Json. You can fix this by manually altering the column type:
ALTER TABLE "YourTable" ALTER COLUMN "descriptor" TYPE JSONB USING "descriptor"::jsonb;

ALTER TABLE "YourTable" ALTER COLUMN "descriptor" TYPE JSONB USING "descriptor"::jsonb;

After this, run prisma introspect again. Now, Prisma should recognize the column as Json in your schemaJson type is represented as TEXT in database. 2. Introspection: When you run prisma introspect, Prisma maps PostgreSQL json and jsonb columns to the Json type in your Prisma schema. If the column is not recognized, check the actual column type in your databaseType mapping between PostgreSQL and Prisma schema. 3. Schema Caching: Sometimes, your editor or Prisma CLI might cache an old schema. Try restarting your editor and re-running prisma generate after introspection. 4. Prisma Version: Ensure you are using a recent version of Prisma, as older versions may have bugs or lack full support for JSON typesPrisma Schema Error with Json Type. If you have confirmed the column is of type json or jsonb and Prisma still does not recognize it, please provide the output of prisma introspect and your current schema.prisma for further troubleshooting. āœ… Great, thanks for letting us know that this solved your question!
Nurul
Nurul•2w ago
Glad to see that the bot was helpful šŸ™
guizin
guizinOP•2w ago
I almost clicked that I didnt want to speak to any bot, because it almost never really helps, but that was impressively helpful ; )
Nurul
Nurul•7d ago
That's very good to know šŸ™‚

Did you find this page helpful?