correct index on name value to drop long values

This commit is contained in:
Sam 2015-07-28 10:50:02 +10:00
parent d5299001ca
commit ea5ef3bcf6
2 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,14 @@
class AddIndexToPostCustomFields < ActiveRecord::Migration
def change
add_index :post_custom_fields, [:name, :value]
def up
execute <<SQL
CREATE INDEX index_post_custom_fields_on_name_and_value ON post_custom_fields USING btree (name, left(value, 200))
SQL
end
def down
execute <<SQL
DROP INDEX index_post_custom_fields_on_name_and_value
SQL
end
end

View File

@ -0,0 +1,15 @@
class CorrectCustomFieldsMigration < ActiveRecord::Migration
def up
execute <<SQL
DROP INDEX index_post_custom_fields_on_name_and_value
SQL
execute <<SQL
CREATE INDEX index_post_custom_fields_on_name_and_value ON post_custom_fields USING btree (name, left(value, 200))
SQL
end
def down
# nothing, no point rolling this back, we rewrote history
end
end