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

[6.x] Revert "Revert cascading truncations" #34497

Merged
merged 1 commit into from Sep 23, 2020
Merged

Conversation

taylorotwell
Copy link
Member

Reverts #34496

@taylorotwell taylorotwell merged commit 53990b1 into 6.x Sep 23, 2020
@GrahamCampbell GrahamCampbell deleted the revert-34496-6.x branch September 23, 2020 15:58
@GrahamCampbell GrahamCampbell changed the title Revert "Revert cascading truncations" [6.x] Revert "Revert cascading truncations" Sep 23, 2020
@crazyscience
Copy link

@taylorotwell Can you explain why this was reverted? You realize that this code causes EVERY table to be truncated that has a related constraint to the one referenced in DB::truncate() right? So, if you follow a typical design pattern where all of your tables are constrained with foreign keys, DB::truncate('anything') results in large-scale data destruction. That's super dangerous and isn't expected behavior when someone is doing DB::truncate('just-one-table').

@crazyscience
Copy link

https://www.postgresql.org/docs/9.1/sql-truncate.html

CASCADE

Automatically truncate all tables that have foreign-key references to any of the named tables, or to any tables added to the group due to CASCADE.

As a note, this behavior OVERRIDES any ON DELETE that you may have set in the database.

@blakethepatton
Copy link
Contributor

@taylorotwell could you please explain the reasoning behind this reversion?

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

Successfully merging this pull request may close these issues.

None yet

3 participants