mirror of
https://github.com/discourse/discourse.git
synced 2026-07-29 15:54:48 -05:00
correct index on name value to drop long values
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
class AddIndexToPostCustomFields < ActiveRecord::Migration
|
class AddIndexToPostCustomFields < ActiveRecord::Migration
|
||||||
def change
|
def up
|
||||||
add_index :post_custom_fields, [:name, :value]
|
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
|
||||||
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
|
||||||
Reference in New Issue
Block a user