diff --git a/db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb b/db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
index <HASH>..<HASH> 100644
--- a/db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
+++ b/db/migrate/20171222120314_add_constraints_on_discovery_rules_hostgroups.rb
@@ -1,6 +1,10 @@
  class AddConstraintsOnDiscoveryRulesHostgroups < ActiveRecord::Migration[4.2]
   def change
-    DiscoveryRule.unscoped.where("hostgroup_id IS NULL OR hostgroup_id NOT IN (?)", Hostgroup.unscoped.all.pluck(:id)).delete_all
+    reversible do |dir|
+      dir.up do
+        DiscoveryRule.unscoped.where("hostgroup_id IS NULL OR hostgroup_id NOT IN (?)", Hostgroup.unscoped.all.pluck(:id)).delete_all
+      end
+    end
     add_foreign_key "discovery_rules", "hostgroups", name: "discovery_rules_hostgroup_id_fk", :column => "hostgroup_id"
   end
  end
Refs #<I> - rules foreign key rollback works