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

[EPIC] Re-Introspection #2829

Closed
7 tasks done
janpio opened this issue Jun 23, 2020 · 19 comments · Fixed by prisma/prisma-engines#1061
Closed
7 tasks done

[EPIC] Re-Introspection #2829

janpio opened this issue Jun 23, 2020 · 19 comments · Fixed by prisma/prisma-engines#1061
Assignees
Labels
kind/feature A request for a new feature. tech/engines/introspection engine Issue in the Introspection Engine tech/engines Issue for tech Engines. topic: previewFeatures Issue touches on an preview feature flag topic: re-introspection
Milestone

Comments

@janpio
Copy link
Member

janpio commented Jun 23, 2020

We want to remove one of the remaining big pain points of Introspection: If you manually adjusted your data model after introspection (to rename fields or models, or add default IDs for example) these changes are currently lost once you introspect again ("re-introspect", for example, because your database was changed manually or migrated by another tool).

This project consists of many individual problems that we are tackling one by one:

We might also decide that some of them are not worth the effort.

Some more issues are listed related to this under: topic: re-introspection

@janpio janpio added topic: re-introspection kind/feature A request for a new feature. labels Jun 23, 2020
@janpio janpio added the tech/engines Issue for tech Engines. label Jun 23, 2020
@janpio
Copy link
Member Author

janpio commented Jun 24, 2020

With 2.1.0 we shipped the experimental flag --experimental-reintrospection that can be used in npx prisma introspect --experimental-reintrospection.

Behind that flag we implemented the first two pieces of Re-Introspection, #2503 and #2545

Please leave feedback on how this feature works for you. We are interested in both positive and negative feedback, so we know if this feature is already ready for production.

@kennytraction
Copy link

kennytraction commented Jun 25, 2020

Thanks for putting the effort into this feature. It is greatly appreciated!

We have only had a few issues with re-introspection:

@janpio
Copy link
Member Author

janpio commented Jun 25, 2020

I tested prisma introspect --experimental-reintrospection on the database @nikolasburk posted in another issue, where he used @@map and renamed relation fields: #2425 (comment) All changes were kept 🚀

@theneshofficial

This comment has been minimized.

@Akxe

This comment has been minimized.

@janpio

This comment has been minimized.

@Akxe

This comment has been minimized.

@michaellzc

This comment has been minimized.

@janpio janpio changed the title Re-Introspection [EPIC] Re-Introspection Jul 3, 2020
@janpio janpio added this to the 2.3.0 milestone Jul 7, 2020
@janpio janpio modified the milestones: 2.3.0, 2.4.0 Jul 21, 2020
@janpio janpio modified the milestones: 2.4.0, Backlog 2.5.0 Aug 4, 2020
@janpio janpio added the topic: previewFeatures Issue touches on an preview feature flag label Aug 5, 2020
@mavilein mavilein added the tech/engines/introspection engine Issue in the Introspection Engine label Aug 6, 2020
@janpio
Copy link
Member Author

janpio commented Aug 20, 2020

Quick update:

We just merged the last planned feature here 🚀

If you install the dev version with npm install @prisma/cli@dev you will get the state we are planning to launch with 2.6.0 as part of the prisma introspect functionality. Further improvement would be merged into the main feature then in the future directly if we find anything else to do.

For now you can still test it with: npx prisma introspect --experimental-reintrospection

It would be great if you all could test this again, before we go into the final integration with #3331 and see if your use cases are covered now - and let us know if not.

(Pinging some people from this and other related issues for visibility: @Akxe @ExiaSR @theneshofficial @kennytraction @theRocket @louisrli @harryttd)

@kennytraction
Copy link

@janpio When will a new dev package be available? It seems the current one (2.6.0-dev.9) doesn't have @updateAt changes. That is the only remaining issue we have.

@bkrausz
Copy link

bkrausz commented Aug 20, 2020

Sounds like you're on the tail end of dev work here, but any chance of getting eyes on #3076? tl;dr - reintrospection is incorrect in a particularly bad way when using partial unique indexes, having Prisma ignore them rather than incorrectly assume they're globally unique would be a large improvement in usability for us.

@janpio
Copy link
Member Author

janpio commented Aug 20, 2020

@kennytraction Ahem, there should be a 2.6.0-dev.11 now - seems I was to quick to post here.

@janpio
Copy link
Member Author

janpio commented Aug 20, 2020

@bkrausz Can you explain the "having Prisma ignore them rather than incorrectly assume they're globally unique would be a large improvement in usability for us." bit over in #3076 please? I thought this was just about adding new functionality - which is prioritized versus the other things we are working on and would not land very high in the list right now, if it is not or we need to improve our understanding we can probably fast track that part.

@kennytraction
Copy link

@kennytraction Ahem, there should be a 2.6.0-dev.11 now - seems I was to quick to post here.

No problem. With that build it seems all of our issues have been addressed.

Thanks!

@do4gr
Copy link
Member

do4gr commented Aug 21, 2020

Since re-introspection is in a good state now we will turn this into the default behavior, meaning
prisma introspect will take in the existing schema and use it to enrich the schema taken from the database. If the previous schema contains errors, the command will abort and return the errors.

prisma introspect --force will allow you to ignore the previous schema and return a schema purely based on the database.

We just need product sign off on the naming for the extra flag here:

  • --force
  • --overwrite
  • --clean

Are all options we have considered.

@Akxe
Copy link
Contributor

Akxe commented Aug 21, 2020

How about --ignore-schema? It is to me more descriptive.

@albertoperdomo
Copy link
Contributor

After some internal discussions, we've settled on using --force.

Feedback on the alternative options considered:

  • --overwrite - both introspection and re-introspection overwrite the existing file so this seems inaccurate and be misinterpreted
  • --clean - could be interpreted in multiple ways, i.e. clean up the file, start from clean slate, etc.
  • --ignore-schema - describes behavior accurately but feels verbose.

@Akxe
Copy link
Contributor

Akxe commented Aug 21, 2020

@albertoperdomo You can always provide an alias: --ignore-schema, or alias -i

This corresponds to the way npm shorten install to i, update to u and so on...

@janpio
Copy link
Member Author

janpio commented Aug 27, 2020

Finished via #3445 which closed #3331 🚀

Re-Introspection will now be the default behavior when you run prisma introspect and already content in your schema.prisma file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. tech/engines/introspection engine Issue in the Introspection Engine tech/engines Issue for tech Engines. topic: previewFeatures Issue touches on an preview feature flag topic: re-introspection
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants