db: drop dependency on Postgres test_parser extension.

Drop the final dependency on the Postgres test_parser extension.

We also have to remove references to test_parser in the migration where
it was first defined, otherwise replaying all migrations from the
beginning will fail. Replaying all migrations from the beginning
normally isn't done except in testing.

After this, it should be possible to use a vanilla install of Postgres
with Danbooru. It's still recommended to use Danbooru's Docker image for
Postgres (https://ghcr.io/danbooru/postgres), as other Postgres extensions
may be necessary in the future.
This commit is contained in:
evazion
2021-10-14 01:53:21 -05:00
parent c8e4dceedb
commit d50cfdb856
4 changed files with 77 additions and 103 deletions

View File

@@ -75,32 +75,40 @@ class CreatePosts < ActiveRecord::Migration[4.2]
execute "SET statement_timeout = 0"
execute "SET search_path = public"
execute "CREATE OR REPLACE FUNCTION testprs_start(internal, int4)
RETURNS internal
AS '$libdir/test_parser'
LANGUAGE C STRICT"
#execute "CREATE OR REPLACE FUNCTION testprs_start(internal, int4)
#RETURNS internal
#AS '$libdir/test_parser'
#LANGUAGE C STRICT"
execute "CREATE OR REPLACE FUNCTION testprs_getlexeme(internal, internal, internal)
RETURNS internal
AS '$libdir/test_parser'
LANGUAGE C STRICT"
#execute "CREATE OR REPLACE FUNCTION testprs_getlexeme(internal, internal, internal)
#RETURNS internal
#AS '$libdir/test_parser'
#LANGUAGE C STRICT"
execute "CREATE OR REPLACE FUNCTION testprs_end(internal)
RETURNS void
AS '$libdir/test_parser'
LANGUAGE C STRICT"
#execute "CREATE OR REPLACE FUNCTION testprs_end(internal)
#RETURNS void
#AS '$libdir/test_parser'
#LANGUAGE C STRICT"
execute "CREATE OR REPLACE FUNCTION testprs_lextype(internal)
RETURNS internal
AS '$libdir/test_parser'
LANGUAGE C STRICT"
#execute "CREATE OR REPLACE FUNCTION testprs_lextype(internal)
#RETURNS internal
#AS '$libdir/test_parser'
#LANGUAGE C STRICT"
#execute "CREATE TEXT SEARCH PARSER testparser (
# START = testprs_start,
# GETTOKEN = testprs_getlexeme,
# END = testprs_end,
# HEADLINE = pg_catalog.prsd_headline,
# LEXTYPES = testprs_lextype
#)"
execute "CREATE TEXT SEARCH PARSER testparser (
START = testprs_start,
GETTOKEN = testprs_getlexeme,
END = testprs_end,
START = pg_catalog.prsd_start,
GETTOKEN = pg_catalog.prsd_nexttoken,
END = pg_catalog.prsd_end,
HEADLINE = pg_catalog.prsd_headline,
LEXTYPES = testprs_lextype
LEXTYPES = pg_catalog.prsd_lextype
)"
execute "CREATE INDEX index_posts_on_tags_index ON posts USING gin (tag_index)"