mirror of
https://github.com/discourse/discourse.git
synced 2025-04-14 22:21:41 +08:00
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
|
||||
|
15
db/migrate/20150728004647_correct_custom_fields_migration.rb
Normal file
15
db/migrate/20150728004647_correct_custom_fields_migration.rb
Normal 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
|
Loading…
x
Reference in New Issue
Block a user