Open jekuno opened 7 years ago
Automating destruction of data doesn't seem wise to me. It's better that the developers knows exactly what they are doing. Rails is full of examples where such statements must explicitly be placed in each model. Danger lurks ahead.
On Thu, Feb 2, 2017, 02:05 jekuno notifications@github.com wrote:
Currently you have to manually add relations such as has_many :animals, dependent: :destroy for all tenanted models to tenant.rb.
Idea: Extend milia to automatically add has_many :my_tenanted_model, dependent: destroy associations for all tenenated models.
Does anybody have an opinion on this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jekuno/milia/issues/67, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZDDOmx4MMNMv-xvAQJJhiWvAwYm1Eaks5rYapVgaJpZM4L06xm .
I agree with @dsaronin on this one. Deletion of tenanted models should be explicitly defined.
If your applications grows over the years several developers will add more and more tenanted models. IMHO sooner or later somebody will forget to add the according has_many :my_tenanted_model, dependent: destroy
which leads to orphaned records as soon as you destroy a tenant.
Can you imagine any situation where it would be wise to delete a tenant (i.e. company or organization) but to keep records which belong to this tenant? If you want this for recovery reasons you would probably want a consistent solution for all records e.g. by using https://github.com/rubysherpas/paranoia.
Currently you have to manually add relations such as
has_many :animals, dependent: :destroy
for all tenanted models totenant.rb
.Idea: Extend milia to automatically add
has_many :my_tenanted_model, dependent: destroy
associations for all tenenated models.Does anybody have an opinion on this?