Skip to content

Preview feature feedback: Referential Actions (referentialActions) #7816

Closed

Description

@janpio

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)

Activity

  1. changed the title [-]Placeholder issue for referential actions preview feature[/-] [+][Placeholder] Preview feature feedback: Referential Actions (`...`)[/+] on Jun 22, 2021
  2. changed the title [-][Placeholder] Preview feature feedback: Referential Actions (`...`)[/-] [+][Placeholder] Preview feature feedback: Referential Actions (`referentialActions`)[/+] on Jun 25, 2021
  3. changed the title [-][Placeholder] Preview feature feedback: Referential Actions (`referentialActions`)[/-] [+]Preview feature feedback: Referential Actions (`referentialActions`)[/+] on Jun 29, 2021
  4. FlorianWendelborn commented on Jun 29, 2021

    @FlorianWendelborn

    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.

  5. janpio commented on Jun 29, 2021

    @janpio
    ContributorAuthor

    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.

  6. diegoazh commented on Jun 30, 2021

    @diegoazh

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

  7. SvenC56 commented on Jun 30, 2021

    @SvenC56

    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
    
  8. janpio commented on Jun 30, 2021

    @janpio
    ContributorAuthor

    @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).

  9. SvenC56 commented on Jun 30, 2021

    @SvenC56

    @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.
    
  10. janpio commented on Jun 30, 2021

    @janpio
    ContributorAuthor

    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.

  11. Mikastark commented on Jun 30, 2021

    @Mikastark

    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 :)

  12. ruslanguns commented on Jul 1, 2021

    @ruslanguns

    @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.

  13. ruslanguns commented on Jul 1, 2021

    @ruslanguns

    @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?

  14. janpio commented on Jul 2, 2021

    @janpio
    ContributorAuthor
    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.

  15. cobnett3 commented on Jul 2, 2021

    @cobnett3

    It worked! Great!!

  16. PabloSzx commented on Jul 6, 2021

    @PabloSzx
    • 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?

  17. tomhoule commented on Jul 6, 2021

    @tomhoule
    Contributor

    @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.

  18. tlindener commented on Jul 13, 2021

    @tlindener
  19. janpio commented on Jul 13, 2021

    @janpio
    Author
  20. tlindener commented on Jul 14, 2021

    @tlindener

    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

  21. added this to the 2.31.0 / 3.0.x milestone on Aug 19, 2021
  22. 2color commented on Sep 7, 2021

    @2color
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: previewFeaturestopic: referential actions

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions