This topic needs a title

While working on one of the org deletion bugs (
Bug #15336: Org/Location removal results in a ISE - Foreman) I hit upon this inconsistency
in Foreman code base and would like suggestions on the agreeable behavior.

So here is the user action

  1. User creates an org
  2. Assigns a host to that org
  3. Deletes that org

There seem to be 2 different approaches taken in the foreman code
1)


seems to indicate the intention to nullify the organization-host
association if organization gets deleted. This tells me that its ok to
delete the org with hosts associated to it.
"has_many_hosts :dependent => :nullify"

https://github.com/theforeman/foreman/blob/develop/test/functional/api/v2/locations_controller_test.rb#L74
seems to indicate we do Not want to delete orgs/locations if hosts are
attached to it. "should NOT destroy location if hosts use it" .

Looking at the commit dates for both, they were merged a mere month after
each other (jan - feb 2013). 2 came before 1 .

I prefer 1 over 2 … Unassociate the Org from the Host if the org gets
deleted instead of blocking the delete. Whats your preferred approach.
Kindly let me know.

Partha