question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma introspect is deleting models I created for database views

See original GitHub issue

Bug 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 generate it works perfectly fine.
  • However, if run prisma introspect, it deletes all my models that I had setup for the database views.

How to reproduce

  1. Create a simple database table.
  2. Create a simple database view (for that table).
  3. In the schema.prisma manually add the model for that database view.
  4. Run yarn prisma introspect.
  5. Check schema.prisma file, 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:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
janpiocommented, Feb 5, 2021

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.

1reaction
janpiocommented, Sep 23, 2021

Closing this issue as https://github.com/prisma/prisma/issues/678 is the only way to make this nicer.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found