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

feat(server): check PG version before running migrations #1868

Merged
merged 1 commit into from Mar 12, 2024

Conversation

xvello
Copy link
Contributor

@xvello xvello commented Mar 12, 2024

To avoid more dupes of #1860, exit the server with a relevant error when PG is outdated.

This is pulling the server_version_num info (you can manually get it with a SHOW server_version_num; query). It's value is major * 10000 + minor, so 160002 for version 16.2. This could allow you to also check the minor version in the future if needed.

Tested

docker run -e POSTGRES_PASSWORD=password -p 54322:5432 postgres:13

ATUIN_DB_URI=postgres://postgres:password@localhost:54322/postgres ./target/debug/atuin server start 
Error: failed to connect to db: PostgresSettings { db_uri: "postgres://postgres:password@localhost:54322/postgres" }

Caused by:
    Other(unsupported PostgreSQL version 13, minimum required is 14

    Location:
        atuin-server-postgres/src/lib.rs:61:39)

Location:
    /home/xavier/git/atuin/atuin-server/src/lib.rs:141:10

Server still starts fine with PG 15.

Checks

  • I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle
  • I have checked that there are no existing pull requests for the same thing

The generated errors are not pretty, feel free to change them.

Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

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

this is great! thank you so much 🙏

@ellie ellie enabled auto-merge (squash) March 12, 2024 18:01
@ellie ellie merged commit c330636 into atuinsh:main Mar 12, 2024
16 checks passed
@xvello xvello deleted the xvello/check-ver branch March 12, 2024 18:04
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.

None yet

2 participants