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

Cascade delete #4198

Closed
Mark-Panda opened this issue Nov 9, 2020 · 5 comments
Closed

Cascade delete #4198

Mark-Panda opened this issue Nov 9, 2020 · 5 comments

Comments

@Mark-Panda
Copy link

MySQL foreign key is CASCADE, but using delete still shows

Invalid `prisma.mother.delete()` invocation in
/Users/maxianfei/Desktop/prismaProject/webserverPrisma/node_modules/nexus-plugin-prisma/dist/schema/builder.js:202:105

 198         locallyComputedInputs: publisherConfig.locallyComputedInputs,
 199     });
 200 }
 201 args = this.paginationStrategy.resolve(args);
→ 202 return prismaClient[mappedField.prismaClientAccessor][mappedField.operation](args)


 The change you are trying to make would violate the required relation 'MotherToMtext' between the `Mother` and `Mtext` models.
   at iy.request (/Users/maxianfei/Desktop/prismaProject/webserverPrisma/node_modules/@prisma/client/runtime/index.js:196:54)
   at process._tickCallback (internal/process/next_tick.js:68:7)
 code: 'P2014',
 meta:
  { relation_name: 'MotherToMtext',
    model_a_name: 'Mother',
    model_b_name: 'Mtext' } }```
@janpio janpio transferred this issue from prisma/docs Nov 9, 2020
@diegozuber
Copy link

diegozuber commented Nov 10, 2020

Same problem here.

@pantharshit00
Copy link
Contributor

Hi,

Thanks for reporting this! It has already been reported before, so I am going to close this as a duplicate of #2810

@diegozuber
Copy link

@pantharshit00 That means this guide is outdated and does not work anymore?

https://www.prisma.io/docs/guides/database-workflows/cascading-deletes/mysql

@pantharshit00
Copy link
Contributor

That guide should still work. This above case is kind of "limitation" of the query engine where is currently validates relations in memory before send the queries.

@diegozuber
Copy link

@pantharshit00 the guide doesn't work for me. If I try this part (https://www.prisma.io/docs/guides/database-workflows/cascading-deletes/mysql#82-validating-cascade) I'm always getting the same error as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants