Skip to content
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

Prisma introspect is deleting models I created for database views #5501

Closed
jacky-lam opened this issue Feb 5, 2021 · 8 comments
Closed

Prisma introspect is deleting models I created for database views #5501

jacky-lam opened this issue Feb 5, 2021 · 8 comments
Labels
kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. topic: introspection

Comments

@jacky-lam
Copy link

jacky-lam commented Feb 5, 2021

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
@janpio
Copy link
Member

janpio commented 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.

@Jolg42 Jolg42 added kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. topic: introspection labels Feb 8, 2021
@jacky-lam
Copy link
Author

thank you @janpio. i will try to use this.

@jacky-lam
Copy link
Author

jacky-lam commented Feb 8, 2021

hi @janpio ,

I just updated my prisma version to 2.16.1 and put the @@ignore tag at the bottom of the model definition as shown in the link you sent.

When i ran yarn prisma introspect it still deleted my model definition. Was that an expected behaviour?

@pantharshit00
Copy link
Contributor

That is unexpected. I will try to reproduce this.

@pantharshit00
Copy link
Contributor

Hey @jacky-lam

Looks like this hasn't been implemented in reintrospection yet: #5331

Please wait on that here.

@pantharshit00
Copy link
Contributor

I suggest you also not use @@ignore in first place as models marked with that gets removed from the client API. The real solution here is having views supported in the schema: #678

@janpio
Copy link
Member

janpio commented Feb 9, 2021

I suggest you also not use @@ignore in first place as models marked with that gets removed from the client API.

That is actually true. So although you would keep the models, you would still not be able to use them. My bad, sorry.

@janpio
Copy link
Member

janpio commented Sep 23, 2021

Closing this issue as #678 is the only way to make this nicer.

@janpio janpio closed this as completed Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. team/schema Issue for team Schema. topic: introspection
Projects
None yet
Development

No branches or pull requests

5 participants