correct index on name value to drop long values
This commit is contained in:
parent
d5299001ca
commit
ea5ef3bcf6
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue