Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-60328] include proper search_path check to post-migrate #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isacikgoz
Copy link
Member

Summary

After every migration, we should advise running migration-assist post-migrate command to determine the health of the DB in terms of schema and it's ownership.

Also make index creation optional. Will add documentation accordingly.

Ticket Link

https://mattermost.atlassian.net/browse/MM-60328

@isacikgoz isacikgoz added the 2: Dev Review Requires review by a core committer label Sep 26, 2024
@galtom
Copy link

galtom commented Sep 27, 2024

This "bug" affected me, and after hours of search I found the solution.
Whet the migration finished I tried to start Mattermost, but it is failed because SELECT CURRENT_SCHEMA(); SQL command returned nothing:

mattermost=> SELECT CURRENT_SCHEMA();
 current_schema
----------------

(1 row)

The SEARCH_PATH looked liked this:

mattermost=> SHOW SEARCH_PATH;
     search_path
---------------------
 """$user"", public"
(1 row)

But it is wrong. To make it work, I had to set by hand the it as postgres user:

ALTER ROLE mmuser SET search_path = "$user", public;

After that, this is what the SEARCH_PATH and CURRENT_SCHEMA() looked like:

mattermost=# SELECT CURRENT_SCHEMA();
 current_schema
----------------
 public
(1 row)

mattermost=# SHOW SEARCH_PATH;
   search_path
-----------------
 "$user", public
(1 row)

Copy link
Member

@agnivade agnivade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, https://mattermost.atlassian.net/browse/MM-60328 was about restoring the schema_search path in case the command failed to run successfully. But this PR just adds a post-migrate check correct?

Can we do something so that the search_path gets restored correctly in case of failure? If not, clearly mention that "command has failed, search_path could not be restored, please reset it manually" or something like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants