cycle / orm

PHP DataMapper, ORM
https://cycle-orm.dev
MIT License
1.23k stars 72 forks source link

Cascading deletes #128

Open SamMousa opened 4 years ago

SamMousa commented 4 years ago

As mentioned in #3, Cycle does not support cascading deletes at this time, instead relying on FKs.

It would be nice to support application-level cascading.

  1. Large migrations directly on the database are slow (table copy of millions of records)
  2. Tools like github's gh-ost work by creating a shadow table and then swapping it, removing the need for long table locks (and thus downtime)
  3. These tools cannot ever work when there are foreign keys since table swapping using renames will not work with foreign keys

In most DBMSes, cascading deletes are relatively simple, and they could even be put into transactions to give the same atomicity as you get when using FKs.

wolfy-j commented 4 years ago

Conceptually we can implement it pretty easily, the set of commands we use to update relations already do deletes in some cases. We can review this feature after freeing the team from current component development and achieving 1.3.0 milestone.