diff --git a/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb b/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb new file mode 100644 index 000000000..cc4b50c78 --- /dev/null +++ b/db/migrate/20170416224142_add_reason_ts_vector_index_to_post_flags_and_appeals.rb @@ -0,0 +1,13 @@ +class AddReasonTsVectorIndexToPostFlagsAndAppeals < ActiveRecord::Migration + def up + execute "SET statement_timeout = 0" + execute "CREATE INDEX index_post_flags_on_reason_tsvector ON post_flags USING gin (to_tsvector('pg_catalog.english', reason))" + execute "CREATE INDEX index_post_appeals_on_reason_tsvector ON post_appeals USING gin (to_tsvector('pg_catalog.english', reason))" + end + + def down + execute "SET statement_timeout = 0" + remove_index :post_flags, name: "index_post_flags_on_reason_tsvector" + remove_index :post_appeals, name: "index_post_appeals_on_reason_tsvector" + end +end diff --git a/db/structure.sql b/db/structure.sql index 17d4b42cb..e54f19e90 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -6836,6 +6836,13 @@ CREATE INDEX index_post_appeals_on_creator_ip_addr ON post_appeals USING btree ( CREATE INDEX index_post_appeals_on_post_id ON post_appeals USING btree (post_id); +-- +-- Name: index_post_appeals_on_reason_tsvector; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_post_appeals_on_reason_tsvector ON post_appeals USING gin (to_tsvector('english'::regconfig, reason)); + + -- -- Name: index_post_approvals_on_post_id; Type: INDEX; Schema: public; Owner: - -- @@ -6885,6 +6892,13 @@ CREATE INDEX index_post_flags_on_creator_ip_addr ON post_flags USING btree (crea CREATE INDEX index_post_flags_on_post_id ON post_flags USING btree (post_id); +-- +-- Name: index_post_flags_on_reason_tsvector; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_post_flags_on_reason_tsvector ON post_flags USING gin (to_tsvector('english'::regconfig, reason)); + + -- -- Name: index_post_votes_on_post_id; Type: INDEX; Schema: public; Owner: - -- @@ -7583,3 +7597,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170414005856'); INSERT INTO schema_migrations (version) VALUES ('20170414233426'); +INSERT INTO schema_migrations (version) VALUES ('20170416224142'); +