Skip to content

Add \c mattermost step to PostgreSQL preparation grants#8920

Merged
ewwollesen merged 4 commits into
masterfrom
fix-postgres-prep-connect-step
Apr 28, 2026
Merged

Add \c mattermost step to PostgreSQL preparation grants#8920
ewwollesen merged 4 commits into
masterfrom
fix-postgres-prep-connect-step

Conversation

@ewwollesen
Copy link
Copy Markdown
Contributor

Summary

In the PostgreSQL preparation steps for v15.x or later (database-preparation step 5e), the ALTER SCHEMA public and GRANT USAGE, CREATE ON SCHEMA public commands operate on the current database's public schema. Without first connecting to the mattermost database, those grants are applied to whatever database the admin happens to be connected to (typically postgres), leaving the actual mattermost database without the required schema permissions.

This PR adds a \c mattermost step between ALTER DATABASE and the schema-level commands so the grants land on the right schema.

Before:

ALTER DATABASE mattermost OWNER TO mmuser;
ALTER SCHEMA public OWNER TO mmuser;
GRANT USAGE, CREATE ON SCHEMA public TO mmuser;

After:

ALTER DATABASE mattermost OWNER TO mmuser;
\c mattermost
ALTER SCHEMA public OWNER TO mmuser;
GRANT USAGE, CREATE ON SCHEMA public TO mmuser;

Test plan

  • Verify the rendered page at deployment-guide/server/preparations.html#database-preparation shows the new \c mattermost line in the step 5e code block.
  • Confirm running the updated sequence in psql against a fresh PostgreSQL 15+ instance results in mmuser owning the public schema of the mattermost database.

🤖 Generated with Claude Code

The ALTER SCHEMA public and GRANT USAGE, CREATE ON SCHEMA public
commands operate on the current database's public schema, so users
must connect to the mattermost database before running them.
Without \c mattermost, these grants are applied to the wrong
database's public schema.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 28, 2026 02:21
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

Warning

Rate limit exceeded

@ewwollesen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 30 minutes and 8 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c2fbf6e-b5d2-4b89-98cd-7e33647e6680

📥 Commits

Reviewing files that changed from the base of the PR and between 1fdd8d1 and b75ae92.

📒 Files selected for processing (1)
  • source/deployment-guide/server/preparations.rst
📝 Walkthrough

Walkthrough

Documentation update to PostgreSQL v15.x+ database preparation instructions adds an explicit connection command (\c mattermost) after setting database ownership, ensuring subsequent schema and grant operations execute in the correct database context.

Changes

Cohort / File(s) Summary
PostgreSQL Setup Documentation
source/deployment-guide/server/preparations.rst
Added \c mattermost command to ensure ALTER SCHEMA and related operations execute within the mattermost database context.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a database connection step to PostgreSQL preparation instructions.
Description check ✅ Passed The description provides comprehensive context explaining the problem, the solution, and test steps; it is directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-postgres-prep-connect-step

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Mattermost Server deployment preparation docs to ensure PostgreSQL schema grants are applied to the correct database when using PostgreSQL v15.x+.

Changes:

  • Adds an explicit \c mattermost step before running schema-level ALTER SCHEMA / GRANT commands in the PostgreSQL v15.x+ preparation flow.

Comment thread source/deployment-guide/server/preparations.rst
@ewwollesen ewwollesen requested a review from hanzei April 28, 2026 02:23
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA 1fdd8d1

Clarifies that the connection switch is what makes the subsequent
ALTER SCHEMA and GRANT commands target the mattermost database's
public schema.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA d209c34

The generic sql lexer flags \c as an unknown token (red error box
in rendered output). The postgresql lexer recognizes psql
meta-commands like \c as builtins, so the block renders cleanly
while still highlighting the SQL statements.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA f4e6162

Both the sql and postgresql Pygments lexers flag backslash-prefixed
psql meta-commands as error tokens (rendered as a red box). Switch
to the text lexer so the block renders cleanly. Loses SQL syntax
highlighting on four lines, but keeps the commands as a single
copy-pasteable unit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Newest code from mattermost has been published to preview environment for Git SHA b75ae92

@ewwollesen
Copy link
Copy Markdown
Contributor Author

@hanzei I am 99% sure that connect step is needed prior to changing those permissions. I'm also pretty certain this is why we have so many search_path and current_schema issues with the Postgres migration.

Copy link
Copy Markdown
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Good catch

@ewwollesen ewwollesen merged commit fde42e5 into master Apr 28, 2026
6 checks passed
@ewwollesen ewwollesen deleted the fix-postgres-prep-connect-step branch April 28, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants