Skip to content

migration-assist: postgres post-migrate gives "could not find the default schema "public" in search_path, consider setting it from the postgresql console" #37

@ylluminate

Description

@ylluminate

After moving through migration steps and successfully loading information via pgloader-main migration.load, I'm hitting an issue that is unclear as to whether it is a problem or not since it doesn't directly state any errors are occurring @agnivade @isacikgoz:

$ ./migration-assist postgres post-migrate "postgres://mmuser_main:REDACTED@192.168.1.93:5432/mattermost_main"
2025-02-01 18:36:39 could not find the default schema "public" in search_path, consider setting it from the postgresql console
2025-02-01 18:36:39 search_path is set to "public" for the currrent session
2025-02-01 18:36:39 running migrations..
2025-02-01 18:36:39 index creation skipped.

You'll notice that it is having problems with the public schema and then it says the search_path seems to be using it in the next line... 😵‍💫

So, I want to understand what I'm facing here and if this is presenting a problem with the migratory process.

To be clear, this is how I'm creating the database - which I think is well and good, but you can correct me if I'm wrong (note how I'm using a user of mmuser_main and database of mattermost_main instead of the normal names since I plan to have a couple mattermost databases in this PostgreSQL server):

export PGPASSWORD='REDACTED'
psql -h 192.168.1.93 -U postgres -c "DROP DATABASE IF EXISTS mattermost_main;" && \
psql -h 192.168.1.93 -U postgres -c "DROP ROLE IF EXISTS mmuser_main;" && \
psql -h 192.168.1.93 -U postgres -c "CREATE ROLE mmuser_main WITH LOGIN ENCRYPTED PASSWORD 'REDACTED2';" && \
psql -h 192.168.1.93 -U postgres -c "CREATE DATABASE mattermost_main WITH OWNER mmuser_main ENCODING 'UTF8' LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8' TEMPLATE=template0;" && \
psql -h 192.168.1.93 -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE mattermost_main TO mmuser_main;" && \
psql -h 192.168.1.93 -U postgres -c "ALTER ROLE mmuser_main SET search_path = public;" && \
psql -h 192.168.1.93 -U postgres -d mattermost_main -c "ALTER SCHEMA public OWNER TO mmuser_main; SELECT schema_name, schema_owner FROM information_schema.schemata WHERE schema_name = 'public';"

As far as I can tell things should be alright with this sanity check:

$ PGPASSWORD='REDACTED2' psql -h 192.168.1.93 -U mmuser_main -d mattermost_main
psql (17.2 (Ubuntu 17.2-1.pgdg22.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off, ALPN: postgresql)
Type "help" for help.

mattermost_main=> select current_database();
 current_database
------------------
 mattermost_main
(1 row)

mattermost_main=> select current_schema();
 current_schema
----------------
 public
(1 row)

mattermost_main=> show search_path;
 search_path
-------------
 public
(1 row)

mattermost_main=> ALTER user mmuser_main in database mattermost_main set search_path to 'public';
ALTER ROLE
mattermost_main=> quit

Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions