From fbf33f7d29c68118b597f5db894153e0e55c6b57 Mon Sep 17 00:00:00 2001 From: Earlopain Date: Sun, 26 Feb 2023 16:41:02 +0100 Subject: [PATCH] [DB] Remove test_parser extension Usage has been removed in https://github.com/e621ng/e621ng/commit/5215876862d3fa81a032c6726aa5b5c2b356d632 and pr #476 --- app/models/application_record.rb | 8 -- app/models/post.rb | 2 +- .../20230226152600_remove_testparser.rb | 12 +++ db/structure.sql | 77 +------------------ docker-compose.yml | 2 +- docker/postgres/Dockerfile | 10 --- 6 files changed, 16 insertions(+), 95 deletions(-) create mode 100644 db/migrate/20230226152600_remove_testparser.rb delete mode 100644 docker/postgres/Dockerfile diff --git a/app/models/application_record.rb b/app/models/application_record.rb index e5aa5a5af..67396100b 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -210,14 +210,6 @@ class ApplicationRecord < ActiveRecord::Base end end - concerning :PostgresExtensions do - class_methods do - def columns(*params) - super.reject {|x| x.sql_type == "tsvector"} - end - end - end - concerning :SimpleVersioningMethods do class_methods do def simple_versioning(options = {}) diff --git a/app/models/post.rb b/app/models/post.rb index 7c8202830..1e35dcebb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1402,7 +1402,7 @@ class Post < ApplicationRecord module ApiMethods def hidden_attributes - list = super + [:tag_index, :pool_string, :fav_string] + list = super + [:pool_string, :fav_string] if !visible? list += [:md5, :file_ext] end diff --git a/db/migrate/20230226152600_remove_testparser.rb b/db/migrate/20230226152600_remove_testparser.rb new file mode 100644 index 000000000..c8306dde8 --- /dev/null +++ b/db/migrate/20230226152600_remove_testparser.rb @@ -0,0 +1,12 @@ +class RemoveTestparser < ActiveRecord::Migration[7.0] + def up + execute "DROP TRIGGER trigger_posts_on_tag_index_update ON posts" + remove_column :posts, :tag_index + + execute "DROP TEXT SEARCH CONFIGURATION danbooru" + execute "DROP TEXT SEARCH PARSER testparser" + %i[testprs_start testprs_lextype testprs_getlexeme testprs_end].each do |function| + execute "DROP FUNCTION #{function}" + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 15008ceb6..b972f3cb5 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -40,65 +40,6 @@ END; $$; --- --- Name: testprs_end(internal); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.testprs_end(internal) RETURNS void - LANGUAGE c STRICT - AS '$libdir/test_parser', 'testprs_end'; - - --- --- Name: testprs_getlexeme(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.testprs_getlexeme(internal, internal, internal) RETURNS internal - LANGUAGE c STRICT - AS '$libdir/test_parser', 'testprs_getlexeme'; - - --- --- Name: testprs_lextype(internal); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.testprs_lextype(internal) RETURNS internal - LANGUAGE c STRICT - AS '$libdir/test_parser', 'testprs_lextype'; - - --- --- Name: testprs_start(internal, integer); Type: FUNCTION; Schema: public; Owner: - --- - -CREATE FUNCTION public.testprs_start(internal, integer) RETURNS internal - LANGUAGE c STRICT - AS '$libdir/test_parser', 'testprs_start'; - - --- --- Name: testparser; Type: TEXT SEARCH PARSER; Schema: public; Owner: - --- - -CREATE TEXT SEARCH PARSER public.testparser ( - START = public.testprs_start, - GETTOKEN = public.testprs_getlexeme, - END = public.testprs_end, - HEADLINE = prsd_headline, - LEXTYPES = public.testprs_lextype ); - - --- --- Name: danbooru; Type: TEXT SEARCH CONFIGURATION; Schema: public; Owner: - --- - -CREATE TEXT SEARCH CONFIGURATION public.danbooru ( - PARSER = public.testparser ); - -ALTER TEXT SEARCH CONFIGURATION public.danbooru - ADD MAPPING FOR word WITH simple; - - SET default_tablespace = ''; SET default_table_access_method = heap; @@ -1643,7 +1584,6 @@ CREATE TABLE public.posts ( last_comment_bumped_at timestamp without time zone, fav_count integer DEFAULT 0 NOT NULL, tag_string text DEFAULT ''::text NOT NULL, - tag_index tsvector, tag_count integer DEFAULT 0 NOT NULL, tag_count_general integer DEFAULT 0 NOT NULL, tag_count_artist integer DEFAULT 0 NOT NULL, @@ -4071,13 +4011,6 @@ CREATE INDEX index_posts_on_string_to_array_tag_string ON public.posts USING gin ALTER INDEX public.index_posts_on_string_to_array_tag_string ALTER COLUMN 1 SET STATISTICS 3000; --- --- Name: index_posts_on_tags_index; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_posts_on_tags_index ON public.posts USING gin (tag_index); - - -- -- Name: index_posts_on_uploader_id; Type: INDEX; Schema: public; Owner: - -- @@ -4379,13 +4312,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: posts trigger_posts_on_tag_index_update; Type: TRIGGER; Schema: public; Owner: - --- - -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: staff_audit_logs fk_rails_02329e5ef9; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -4691,6 +4617,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20230210092829'), ('20230219115601'), ('20230221145226'), -('20230221153458'); +('20230221153458'), +('20230226152600'); diff --git a/docker-compose.yml b/docker-compose.yml index cc0b66271..f98ad8faa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,7 +58,7 @@ services: - "3000:3000" postgres: - build: ./docker/postgres + image: postgres:12-alpine environment: - POSTGRES_USER=danbooru - POSTGRES_HOST_AUTH_METHOD=trust diff --git a/docker/postgres/Dockerfile b/docker/postgres/Dockerfile deleted file mode 100644 index 4607cd5f9..000000000 --- a/docker/postgres/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM postgres:12-alpine -ARG BUILD_DEPS="git make gcc libc-dev clang llvm" - -ADD https://api.github.com/repos/r888888888/test_parser/git/refs/heads/master /tmp/test_parser_version.json -RUN apk --no-cache add $BUILD_DEPS \ - && git clone https://github.com/r888888888/test_parser.git /tmp/test_parser \ - && cd /tmp/test_parser \ - && make -j$(nproc) install \ - && rm -rf /tmp/test_parser \ - && apk del $BUILD_DEPS