A platform for community discussion. Free, open, simple.
FIX: do not insert conflict rows into category user
Sam Saffronf49ef851dff8
diff --git a/db/post_migrate/20191107190330_remove_suppress_from_latest_from_category.rb b/db/post_migrate/20191107190330_remove_suppress_from_latest_from_category.rbindex f188cc18927..7d047c17c07 100644--- a/db/post_migrate/20191107190330_remove_suppress_from_latest_from_category.rb+++ b/db/post_migrate/20191107190330_remove_suppress_from_latest_from_category.rb@@ -15,7 +15,8 @@ class RemoveSuppressFromLatestFromCategory < ActiveRecord::Migration[6.0]# We shouldn't encourage to have more than 10 categories in `default_categories_muted` site setting.if ids.count <= 10- DB.exec(<<~SQL, muted: CategoryUser.notification_levels[:muted])+ # CategoryUser.notification_levels[:muted] is 0, avoid reaching to object model+ DB.exec(<<~SQL, muted: 0)INSERT INTO category_users (category_id, user_id, notification_level)SELECT c.id category_id, u.id user_id, :mutedFROM users u@@ -25,6 +26,7 @@ class RemoveSuppressFromLatestFromCategory < ActiveRecord::Migration[6.0]AND c.id = cu.category_idWHERE c.suppress_from_latest = TRUEAND cu.notification_level IS NULL+ ON CONFLICT DO NOTHINGSQLDB.exec(<<~SQL, value: ids.join("|"))