mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 18:13:39 +08:00
BUGFIX: orphan badge groupings
This commit is contained in:
parent
c8284170ad
commit
4feedecce4
|
@ -181,7 +181,10 @@ SQL
|
|||
end
|
||||
|
||||
def default_badge_grouping_id=(val)
|
||||
self.badge_grouping_id ||= val
|
||||
# allow to correct orphans
|
||||
if !self.badge_grouping_id || self.badge_grouping_id < 0
|
||||
self.badge_grouping_id = val
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ end
|
|||
|
||||
# BUGFIX
|
||||
Badge.exec_sql 'UPDATE badges
|
||||
SET badge_grouping_id = NULL
|
||||
SET badge_grouping_id = -1
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM badge_groupings g
|
||||
WHERE g.id = badge_grouping_id
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class SetDefaultBadgeGrouping < ActiveRecord::Migration
|
||||
def change
|
||||
execute 'UPDATE badges SET badge_grouping_id = 5 WHERE badge_grouping_id IS NULL'
|
||||
change_column :badges, :badge_grouping_id, :integer, null: false, default: 5
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user