diff options
Diffstat (limited to 'lib/mauve/history.rb')
-rw-r--r-- | lib/mauve/history.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/mauve/history.rb b/lib/mauve/history.rb index 74c5e3a..5a0caff 100644 --- a/lib/mauve/history.rb +++ b/lib/mauve/history.rb @@ -13,6 +13,8 @@ module Mauve belongs_to :alert belongs_to :history + after :destroy, :remove_unreferenced_histories + def self.migrate! # # This copies the alert IDs from the old History table to the new AlertHistories thing, but only if there are no AertHistories @@ -41,6 +43,12 @@ module Mauve end end + private + + def remove_unreferenced_histories + self.history.destroy unless self.history.alerts.count > 0 + end + end class History |