mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: do not allow tag with name 'none' (#9867)
https://meta.discourse.org/t/none-tag-is-uneditable/152003
This commit is contained in:
17
db/migrate/20200525072638_remove_none_tags.rb
Normal file
17
db/migrate/20200525072638_remove_none_tags.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveNoneTags < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
none_tag_id = DB.query_single("SELECT id FROM tags WHERE lower(name) = 'none'").first
|
||||
if none_tag_id.present?
|
||||
[:tag_users, :topic_tags, :category_tag_stats, :category_tags, :tag_group_memberships].each do |table_name|
|
||||
execute "DELETE FROM #{table_name} WHERE tag_id = #{none_tag_id}"
|
||||
end
|
||||
execute "DELETE FROM tags WHERE id = #{none_tag_id} OR target_tag_id = #{none_tag_id}"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user