From 0cf5a1705a3b498a88212b66211650a2ea7e1ff2 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 20 May 2016 12:35:09 +1000 Subject: [PATCH] FIX: custom field index must only index short values --- ...160520022627_shorten_topic_custom_fields_index.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20160520022627_shorten_topic_custom_fields_index.rb diff --git a/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb b/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb new file mode 100644 index 00000000000..8226c7556f7 --- /dev/null +++ b/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb @@ -0,0 +1,12 @@ +class ShortenTopicCustomFieldsIndex < ActiveRecord::Migration + def up + remove_index :topic_custom_fields, :value + add_index :topic_custom_fields, [:value, :name], + name: 'topic_custom_fields_value_key_idx', + where: 'value IS NOT NULL AND char_length(value) < 400' + end + def down + remove_index :topic_custom_fields, :value, name: 'topic_custom_fields_value_key_idx' + add_index :topic_custom_fields, :value + end +end