mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
correct index on name value to drop long values
This commit is contained in:
parent
d5299001ca
commit
ea5ef3bcf6
2 changed files with 26 additions and 2 deletions
|
@ -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
|
||||||
|
|
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…
Reference in a new issue