aws-amplify / amplify-studio

AWS Amplify Studio (Formerly Admin UI)
136 stars 31 forks source link

Unexpected Cascade Deletion in 1-to-1 Relationships with AWS Amplify #1084

Open logi-richi opened 10 months ago

logi-richi commented 10 months ago

Before opening, please confirm:

App Id

d3gamlam9hvbcr

Region

ap-southeast-1

Environment name

staging

Figma File Version (if applicable)

No response

Amplify CLI Version

12.10.0

If applicable, what version of Node.js are you using?

v18.0.0

What operating system are you using?

No response

Browser type?

No response

Describe the bug

Brief Description

Issue: I am experiencing an issue where the content of Model B is being deleted upon the deletion of a related Model A in a 1-to-1 relationship using AWS Amplify. This happens despite the absence of an explicit configuration for cascade deletion. Expected Behavior: The anticipated behavior is that the deletion of an instance of Model A should not impact the data of the related instance in Model B unless a cascade delete or similar functionality is explicitly set up.

Steps to Reproduce

Environment Setup: AWS Amplify version: 12.10.0

Schema:

type ModelA @model @auth(rules: [{allow: public}]) {
  id: ID!
  email: AWSEmail!
  createdAt: AWSDateTime
  ModelB: ModelB @hasOne
}

type ModelB @model @auth(rules: [{allow: public}]) {
  id: ID!
  email: AWSEmail!
  createdAt: AWSDateTime
}

Steps take:

  1. Create one content in ModelB table
  2. Create one content in ModelA table with relationship to ModelB table content created in previous step
  3. Delete content in ModelA table

Observed Result: The associated content in ModelB table was also deleted.

Expected behavior

Content in ModelB table should not be deleted.

Reproduction steps

  1. Create one content in ModelB table
  2. Create one content in ModelA table with relationship to ModelB table content created in previous step
  3. Delete content in ModelA table

Project Identifier

No response

Additional information

No response

ykethan commented 9 months ago

Hey @logi-richi, From the reproduction steps provided and the data model, I was not able to reproduce the issue. After the delete operation, could you check the DynamoDB table for modelB if the record has been deleted?

edbienes commented 9 months ago

I experienced the same issue with my project. I checked from DynamoDB table, record marks as _deleted = true.