-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add a limitation involving cascade deletions on a circular dependency #19 #21
Add a limitation involving cascade deletions on a circular dependency #19 #21
Conversation
README.md
Outdated
@@ -34,6 +34,7 @@ To solve the preceding issues, this tool works as follows. | |||
|
|||
* This tool does not guarantee the atomicity of deletion. If you access the rows that are being deleted, you will get the inconsistent view of the database. | |||
* This tool does not delete rows which were inserted while the tool was running. | |||
* This tool does not support scenarios involving foreign key constraints with 'ON DELETE CASCADE' in cases where there is a circular dependency among the tables. As a result, it may not be able to truncate the tables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we have at least two scenarios that don't fully work.
- If there is a circular dependency among the tables, truncation will be failed.
- If user uses
--exclude-tables
only for the referencing table that hasON DELETE CASCADE
, that table will be (surprisingly) truncated by cascade-deletion of the referenced table.
If it's correct, we can say something like...
- This tool does not support truncating tables that use foreign key constraints in some scenarios:
- If there is a circular dependency among the tables, truncation will be failed.
- If
--exclude-tables
is used only for the referencing table that hasON DELETE CASCADE
, that table will be truncated by cascade-deletion of the referenced table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If --exclude-tables is used only for the referencing table that has
ON DELETE CASCADE
, that table will be truncated by cascade-deletion of the referenced table.
If we need to present detailed scenarios, we may be able to add the following scenario as well.
- If
--tables
is used for a table referenced withON DELETE CASCADE
, the table will be truncated with the referrer tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! Let's use the consistent wording referencing table
and referenced table
as they are used in the public documentation: https://cloud.google.com/spanner/docs/foreign-keys/overview#how-to-define-foreign-keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the consistent wording
referencing table
andreferenced table
This sounds easy to understand. I adopt this.
README.md
Outdated
@@ -34,6 +34,10 @@ To solve the preceding issues, this tool works as follows. | |||
|
|||
* This tool does not guarantee the atomicity of deletion. If you access the rows that are being deleted, you will get the inconsistent view of the database. | |||
* This tool does not delete rows which were inserted while the tool was running. | |||
* This tool does not support truncating tables that use foreign key constraints in some scenarios: | |||
* If there is a circular dependency among the tables, truncation will be failed. | |||
* If `--tables` is used for a referenced table with ON DELETE CASCADE, the table will be truncated with the referencing tables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for different feedback, but referenced table with ON DELETE CASCADE
would be somewhat confusing.
Let's say, we have two tables, Customers
and ShoppingCarts
(borrowed from doc), and ShoppingCarts
table is referencing Customers
table with ON DELETE CASCADE
.
In this example, ShoppingCarts
is the referencing table and Customers
is the referenced table.
If user specifies --tables=Customers
(referenced table), then ShoppingCarts
(referencing table) is also truncated as a effect of ON DELETE CASCADE
.
So maybe the following might be clearer? If --tables is used for a table that is referenced by other tables with ON DELETE CASCADE, such tables will also be truncated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If --tables is used for a table that is referenced by other tables with ON DELETE CASCADE, such tables will also be truncated.
This sounds clearer! Thank you.
referenced table with ON DELETE CASCADE
would be somewhat confusing.
If I understand correctly, your point is that the foreign key constraint is placed on the referencing table, not on the referenced table, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, your point is that the foreign key constraint is placed on the referencing table, not on the referenced table, right?
Yes, that's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shuto-facengineer LGTM. Thank you for compiling the information and updating the doc!
This PR serves as a temporary measure for issue #19 by adding a note of the limitation to the README.
I'm not very confident in my English writing, so I would appreciate it if you could proofread my text.