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

Preview feature feedback: Referential Actions (referentialActions) #7816

Closed
2 of 3 tasks
Tracked by #8628
janpio opened this issue Jun 22, 2021 · 18 comments
Closed
2 of 3 tasks
Tracked by #8628

Preview feature feedback: Referential Actions (referentialActions) #7816

janpio opened this issue Jun 22, 2021 · 18 comments
Labels
kind/feedback Issue for gathering feedback. team/client Issue for team Client. team/schema Issue for team Schema. topic: previewFeatures Issue touches on an preview feature flag topic: referential actions

Comments

@janpio
Copy link
Member

janpio commented Jun 22, 2021

Please share your feedback about the referentialActions functionality released in v2.26.0 in this issue.

  • If you encounter a bug, please open a bug report in this repo.
  • If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.

If you have any questions, don't hesitate to ask them in the #prisma-client channel in the Prisma Slack.

Known Limitations

VSCode extension/language tool

  • No auto complete for available actions (issue)
  • Autocomplete does not work for arguments after the first one in @relation() (issue)
  • Actions show up in auto complete even without preview feature (issue)
@janpio janpio added kind/feedback Issue for gathering feedback. topic: previewFeatures Issue touches on an preview feature flag labels Jun 22, 2021
@janpio janpio added team/client Issue for team Client. team/schema Issue for team Schema. labels Jun 22, 2021
@janpio janpio changed the title Placeholder issue for referential actions preview feature [Placeholder] Preview feature feedback: Referential Actions (...) Jun 22, 2021
@janpio janpio changed the title [Placeholder] Preview feature feedback: Referential Actions (...) [Placeholder] Preview feature feedback: Referential Actions (referentialActions) Jun 25, 2021
@janpio janpio changed the title [Placeholder] Preview feature feedback: Referential Actions (referentialActions) Preview feature feedback: Referential Actions (referentialActions) Jun 29, 2021
@FlorianWendelborn
Copy link

The new cascade feature works very well for me now. Upgrading was very simple and I could remove some of the hacks around cascade not working properly (I previously had a transaction that first deleted all related elements and then deleted the item itself).

Only thing that’s missing is as far as I can see the documentation. It’s documented well in the release, but the docs still claim that cascade is impossible.

@janpio
Copy link
Member Author

janpio commented Jun 29, 2021

Documentation PR is in the works and will be merged in the coming days. It's a complex topic, but all the necessary information should be in the release notes for now - and we will expand on that as soon as possible.

Thanks for the positive feedback @FlorianWendelborn - and thanks for trying it out so quickly.

@diegoazh
Copy link

Thanks for your effort and work and for delivering this greater feature. 👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽

@SvenC56
Copy link

SvenC56 commented Jun 30, 2021

Hey I just upgraded to 2.26.0 deleted node_modules. But the Prisma Language Server is keeping saying to me:

The preview feature "referentialActions" is not known. Expected one of: microsoftSqlServer, orderByRelation, nApi, selectRelationCount, orderByAggregateGroup, filterJson

@janpio
Copy link
Member Author

janpio commented Jun 30, 2021

@SvenC56 The language server is independent and needs to be updated via the Prisma extension you are using, probably VSCode. Make sure you are running 2.26.0 of the extension as well (usually happens automatically, but sometimes doesn't).

@SvenC56
Copy link

SvenC56 commented Jun 30, 2021

@janpio thank you for your fast feedback. I keep getting this message. I reinstalled the Prisma VSCode Plugin and restarted VSCode.

This is the Output from the language server:

[Info  - 10:22:44] Default version of Prisma binary 'prisma-fmt': 9b816b3aa13cc270074f172f30d6eda8a8ce867d
[Info  - 10:22:44] Extension name @prisma/language-server with version 2.26.0
[Info  - 10:22:44] Prisma CLI version: 2.26.0
Using binary path from Prisma Language Server configuration.
[Info  - 10:22:46] Local prisma-fmt path: /home/ciesloks/Dev/prisma-fmt/prisma-fmt
Binary test successful.
Using binary path from Prisma Language Server configuration.

@janpio
Copy link
Member Author

janpio commented Jun 30, 2021

That version looks correct. Can you open an issue over at https://github.com/prisma/language-tools/issues please? Then we can take a look at it and ask related questions.

@MikaStark
Copy link

MikaStark commented Jun 30, 2021

Amazing feature. Just tried it for one little project in production and it works like a charm. I overuse cascade deletes, and for now it seems stable to me :)

@ruslanguns
Copy link

@SvenC56 I think you should try uninstall prisma from your devDependencies, as well as your @prisma/client from your dependencies, then uninstall the extension from VScode (make sure you restart Vscode as well). Then install all again and try it, I did exactly that and worked to me.

@ruslanguns
Copy link

@janpio that is an amazing waiting feature. Thank you really much.

I'm just wondering, 1) if you're adding this feature to your relation fields, why isn't being reflected in the SQL files generated by the migration command? and in the other hand, 2) if you are using introspection feature to get accesses to an existent database which already supports on delete configurations, will the introspection get those details (or some of them) in the generated prisma schema?

@janpio
Copy link
Member Author

janpio commented Jul 2, 2021

  1. if you're adding this feature to your relation fields, why isn't being reflected in the SQL files generated by the migration command?

That should be the case with the preview feature enabled in 2.26.0. If not, that is a bug.

  1. if you are using introspection feature to get accesses to an existent database which already supports on delete configurations, will the introspection get those details (or some of them) in the generated prisma schema?

Yes, all this should be fully picked up with the preview feature enabled in 2.26.0.

@tsuga
Copy link

tsuga commented Jul 2, 2021

It worked! Great!!

@PabloSzx
Copy link

PabloSzx commented Jul 6, 2021

  • Referential actions can not be specified on relations in implicit many-to-many relations. This limitation can be worked around by switching to explicit many-to-many relations and specifying the referential actions on the relations in the relations table.

How can I migrate existing implicit many-to-many to explicit many-to-many without losing any data to be able to use this workaround?

@tomhoule
Copy link
Contributor

tomhoule commented Jul 6, 2021

@PabloSzx I don't know if there is a better solution, but one approach would be renaming the table (it should be called something like _ModelAToModelB) to something else, then using db pull / introspect and the table would show up in your prisma schema.

@tlindener

This comment has been minimized.

@janpio

This comment has been minimized.

@tlindener
Copy link

Seems like I looked at the wrong place when creating a smaller project. I created a ticket with an approach to reproduce the issue: #8264

@janpio janpio added this to the 2.31.0 / 3.0.x milestone Aug 19, 2021
@2color
Copy link
Contributor

2color commented Sep 7, 2021

Closing this now that this has been released to General Availability in the 3.0.1 release

@2color 2color closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feedback Issue for gathering feedback. team/client Issue for team Client. team/schema Issue for team Schema. topic: previewFeatures Issue touches on an preview feature flag topic: referential actions
Projects
None yet
Development

No branches or pull requests