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

Automatically destroy dependent records #67

Open
jekuno opened this issue Feb 2, 2017 · 3 comments
Open

Automatically destroy dependent records #67

jekuno opened this issue Feb 2, 2017 · 3 comments

Comments

@jekuno
Copy link
Owner

jekuno commented Feb 2, 2017

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?

@dsaronin
Copy link
Contributor

dsaronin commented Feb 2, 2017 via email

@MatthewMarkgraaff
Copy link

I agree with @dsaronin on this one. Deletion of tenanted models should be explicitly defined.

@jekuno
Copy link
Owner Author

jekuno commented Feb 3, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants