diff --git a/app/models/blip.rb b/app/models/blip.rb index e2e1b5e27..a0cc6f2b5 100644 --- a/app/models/blip.rb +++ b/app/models/blip.rb @@ -34,10 +34,6 @@ class Blip < ApplicationRecord end module ApiMethods - def hidden_attributes - super + [:body_index] - end - def method_attributes super + [:creator_name] end diff --git a/app/models/comment.rb b/app/models/comment.rb index 240334eb5..d8c5b2b09 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -200,10 +200,6 @@ class Comment < ApplicationRecord (creator_id == user.id) && user.show_hidden_comments? end - def hidden_attributes - super + [:body_index] - end - def method_attributes super + [:creator_name, :updater_name] end diff --git a/app/models/dmail.rb b/app/models/dmail.rb index e8b9ef0c3..7be9d3df6 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -78,10 +78,6 @@ class Dmail < ApplicationRecord end module ApiMethods - def hidden_attributes - super + [:message_index] - end - def method_attributes super + [:key] end diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index a85947dd7..935482e93 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -89,14 +89,7 @@ class ForumPost < ApplicationRecord end end - module ApiMethods - def hidden_attributes - super + [:text_index] - end - end - extend SearchMethods - include ApiMethods def tag_change_request bulk_update_request || tag_alias || tag_implication diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index cf85d6cfd..d39d53fbe 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -174,10 +174,6 @@ class ForumTopic < ApplicationRecord (response_count / Danbooru.config.posts_per_page.to_f).ceil end - def hidden_attributes - super + [:text_index] - end - def hide! update(is_hidden: true) end diff --git a/app/models/note.rb b/app/models/note.rb index 202ce6cfe..ca3c7b88b 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -58,10 +58,6 @@ class Note < ApplicationRecord end module ApiMethods - def hidden_attributes - super + [:body_index] - end - def method_attributes super + [:creator_name] end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index a0711bc53..2d26920a5 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -120,10 +120,6 @@ class WikiPage < ApplicationRecord end module ApiMethods - def hidden_attributes - super + [:body_index] - end - def method_attributes super + [:creator_name, :category_id, :category_name] end diff --git a/db/migrate/20230221153458_remove_unused_text_index_columns.rb b/db/migrate/20230221153458_remove_unused_text_index_columns.rb new file mode 100644 index 000000000..359a7a624 --- /dev/null +++ b/db/migrate/20230221153458_remove_unused_text_index_columns.rb @@ -0,0 +1,16 @@ +class RemoveUnusedTextIndexColumns < ActiveRecord::Migration[7.0] + def up + drop_trigger_and_column(:blips, :body) + drop_trigger_and_column(:comments, :body) + drop_trigger_and_column(:dmails, :message) + drop_trigger_and_column(:forum_posts, :text) + drop_trigger_and_column(:forum_topics, :text) + drop_trigger_and_column(:notes, :body) + drop_trigger_and_column(:wiki_pages, :body) + end + + def drop_trigger_and_column(table, column) + execute "DROP TRIGGER trigger_#{table}_on_update ON #{table}" + remove_column table, "#{column}_index" + end +end diff --git a/db/structure.sql b/db/structure.sql index 86ff525c4..15008ceb6 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -307,7 +307,6 @@ CREATE TABLE public.blips ( body character varying NOT NULL, response_to integer, is_hidden boolean DEFAULT false, - body_index tsvector NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, warning_type integer, @@ -418,7 +417,6 @@ CREATE TABLE public.comments ( creator_id integer NOT NULL, body text NOT NULL, creator_ip_addr inet NOT NULL, - body_index tsvector NOT NULL, score integer DEFAULT 0 NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, @@ -534,7 +532,6 @@ CREATE TABLE public.dmails ( to_id integer NOT NULL, title text NOT NULL, body text NOT NULL, - message_index tsvector NOT NULL, is_read boolean DEFAULT false NOT NULL, is_deleted boolean DEFAULT false NOT NULL, created_at timestamp without time zone, @@ -779,7 +776,6 @@ CREATE TABLE public.forum_posts ( creator_id integer NOT NULL, updater_id integer NOT NULL, body text NOT NULL, - text_index tsvector NOT NULL, is_hidden boolean DEFAULT false NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, @@ -889,7 +885,6 @@ CREATE TABLE public.forum_topics ( is_sticky boolean DEFAULT false NOT NULL, is_locked boolean DEFAULT false NOT NULL, is_hidden boolean DEFAULT false NOT NULL, - text_index tsvector NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, category_id integer DEFAULT 0 NOT NULL, @@ -1140,7 +1135,6 @@ CREATE TABLE public.notes ( height integer NOT NULL, is_active boolean DEFAULT true NOT NULL, body text NOT NULL, - body_index tsvector NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, version integer DEFAULT 0 NOT NULL @@ -2408,7 +2402,6 @@ CREATE TABLE public.wiki_pages ( creator_id integer NOT NULL, title character varying NOT NULL, body text NOT NULL, - body_index tsvector NOT NULL, is_locked boolean DEFAULT false NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, @@ -3489,13 +3482,6 @@ CREATE INDEX index_bans_on_expires_at ON public.bans USING btree (expires_at); CREATE INDEX index_bans_on_user_id ON public.bans USING btree (user_id); --- --- Name: index_blips_on_body_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_blips_on_body_index ON public.blips USING gin (body_index); - - -- -- Name: index_blips_on_to_tsvector_english_body; Type: INDEX; Schema: public; Owner: - -- @@ -3538,13 +3524,6 @@ CREATE INDEX index_comment_votes_on_created_at ON public.comment_votes USING btr CREATE INDEX index_comment_votes_on_user_id ON public.comment_votes USING btree (user_id); --- --- Name: index_comments_on_body_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_comments_on_body_index ON public.comments USING gin (body_index); - - -- -- Name: index_comments_on_creator_id; Type: INDEX; Schema: public; Owner: - -- @@ -3608,13 +3587,6 @@ CREATE INDEX index_dmails_on_is_deleted ON public.dmails USING btree (is_deleted CREATE INDEX index_dmails_on_is_read ON public.dmails USING btree (is_read); --- --- Name: index_dmails_on_message_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_dmails_on_message_index ON public.dmails USING gin (message_index); - - -- -- Name: index_dmails_on_owner_id; Type: INDEX; Schema: public; Owner: - -- @@ -3685,13 +3657,6 @@ CREATE UNIQUE INDEX index_forum_post_votes_on_forum_post_id_and_creator_id ON pu CREATE INDEX index_forum_posts_on_creator_id ON public.forum_posts USING btree (creator_id); --- --- Name: index_forum_posts_on_text_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_forum_posts_on_text_index ON public.forum_posts USING gin (text_index); - - -- -- Name: index_forum_posts_on_to_tsvector_english_body; Type: INDEX; Schema: public; Owner: - -- @@ -3755,13 +3720,6 @@ CREATE INDEX index_forum_topics_on_creator_id ON public.forum_topics USING btree CREATE INDEX index_forum_topics_on_is_sticky_and_updated_at ON public.forum_topics USING btree (is_sticky, updated_at); --- --- Name: index_forum_topics_on_text_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_forum_topics_on_text_index ON public.forum_topics USING gin (text_index); - - -- -- Name: index_forum_topics_on_to_tsvector_english_title; Type: INDEX; Schema: public; Owner: - -- @@ -3846,13 +3804,6 @@ CREATE INDEX index_note_versions_on_updater_id_and_post_id ON public.note_versio CREATE INDEX index_note_versions_on_updater_ip_addr ON public.note_versions USING btree (updater_ip_addr); --- --- Name: index_notes_on_body_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_notes_on_body_index ON public.notes USING gin (body_index); - - -- -- Name: index_notes_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: - -- @@ -4386,13 +4337,6 @@ CREATE INDEX index_wiki_page_versions_on_updater_ip_addr ON public.wiki_page_ver CREATE INDEX index_wiki_page_versions_on_wiki_page_id ON public.wiki_page_versions USING btree (wiki_page_id); --- --- Name: index_wiki_pages_on_body_index_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_wiki_pages_on_body_index_index ON public.wiki_pages USING gin (body_index); - - -- -- Name: index_wiki_pages_on_other_names; Type: INDEX; Schema: public; Owner: - -- @@ -4435,48 +4379,6 @@ CREATE INDEX index_wiki_pages_on_updated_at ON public.wiki_pages USING btree (up CREATE TRIGGER posts_update_change_seq BEFORE UPDATE ON public.posts FOR EACH ROW EXECUTE FUNCTION public.posts_trigger_change_seq(); --- --- Name: blips trigger_blips_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_blips_on_update BEFORE INSERT OR UPDATE ON public.blips FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); - - --- --- Name: comments trigger_comments_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_comments_on_update BEFORE INSERT OR UPDATE ON public.comments FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); - - --- --- Name: dmails trigger_dmails_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_dmails_on_update BEFORE INSERT OR UPDATE ON public.dmails FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('message_index', 'pg_catalog.english', 'title', 'body'); - - --- --- Name: forum_posts trigger_forum_posts_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_forum_posts_on_update BEFORE INSERT OR UPDATE ON public.forum_posts FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('text_index', 'pg_catalog.english', 'body'); - - --- --- Name: forum_topics trigger_forum_topics_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_forum_topics_on_update BEFORE INSERT OR UPDATE ON public.forum_topics FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('text_index', 'pg_catalog.english', 'title'); - - --- --- Name: notes trigger_notes_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_notes_on_update BEFORE INSERT OR UPDATE ON public.notes FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); - - -- -- Name: posts trigger_posts_on_tag_index_update; Type: TRIGGER; Schema: public; Owner: - -- @@ -4484,13 +4386,6 @@ CREATE TRIGGER trigger_notes_on_update BEFORE INSERT OR UPDATE ON public.notes F CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON public.posts FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string', 'fav_string', 'pool_string'); --- --- Name: wiki_pages trigger_wiki_pages_on_update; Type: TRIGGER; Schema: public; Owner: - --- - -CREATE TRIGGER trigger_wiki_pages_on_update BEFORE INSERT OR UPDATE ON public.wiki_pages FOR EACH ROW EXECUTE FUNCTION tsvector_update_trigger('body_index', 'public.danbooru', 'body', 'title'); - - -- -- Name: staff_audit_logs fk_rails_02329e5ef9; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -4795,6 +4690,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20230204141325'), ('20230210092829'), ('20230219115601'), -('20230221145226'); +('20230221145226'), +('20230221153458');