Prisma introspect is deleting models I created for database views
See original GitHub issueBug description
Action: I have create a simple database view in Postgres and then manually add the model for the view as instructed here:
Bug:
- If I run
prisma generateit works perfectly fine. - However, if run
prisma introspect, it deletes all my models that I had setup for the database views.
How to reproduce
- Create a simple database table.
- Create a simple database view (for that table).
- In the
schema.prismamanually add the model for that database view. - Run
yarn prisma introspect. - Check
schema.prismafile, the model for that database view is gone.
Expected behavior
After running yarn prisma introspect, it would not delete the model for the database view.
Prisma information
Environment & setup
- OS: Mac OS
- Database: Postgres
- Node.js version: 12.20.*
- Prisma: 2.15
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
What is introspection? (Reference) - Prisma
Introspection has one main function: Populate your Prisma schema with a data model that reflects the current database schema. ... Here's an overview...
Read more >Referential actions - Prisma
Referential actions let you define the update and delete behavior of related models on the database level.
Read more >Data model (Reference) - Prisma
Models : Represent the entities of your application domain; Map to the tables (relational databases like PostgreSQL) or collections (MongoDB) in your database...
Read more >Data modeling with Prisma
Run prisma db pull to introspect the database and add application models to the Prisma schema; Run prisma generate to update your Prisma...
Read more >CRUD (Reference) - Prisma
Create ; Read; Update; Delete ... $npx prisma db push. For MongoDB, ensure your data is in a uniform shape and matches the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This will solve your problem: https://www.prisma.io/docs/concepts/components/preview-features/native-types/native-types-mappings#ignore-and-ignore Note this is currently just a preview feature that needs to be explicitly enabled.
Closing this issue as https://github.com/prisma/prisma/issues/678 is the only way to make this nicer.