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

Add upgrade scripts for database files #28

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

Conversation

ailox
Copy link

@ailox ailox commented Nov 29, 2024

What

Postgres changes the format of the database files on disk between major versions. This means that in order to upgrade a postgres database, it is not sufficient to just bump the container versions.

To help with this process, we now can use migration scripts that will take care of updating the database version without the need of a manual dump/restore.

Why

pg_upgrade requires the new and old postgres binaries to be present, therefore the image now contains
two postgres versions in parallel. This does affect image size (~35MB increase), but not runtime memory
consumption, as only one version of postgres is ever running at the same time.

References

DEVOPS-1292

Checklist

  • Tests

Postgres changes the format of the database files on disk between major
versions. This means that in order to upgrade a postgres database, it is
not sufficient to just bump the container versions.

To help with this process, we now can use migration scripts that will
take care of updating the database version without the need of a manual
dump/restore.

Ref.: DEVOPS-1292

# Initialize the new database, if it doesn't exist
if [ ! -s "${PGDATANEW}/PG_VERSION" ]; then
gosu postgres initdb -D ${PGDATANEW}
Copy link
Contributor

@pascalholthaus pascalholthaus Dec 2, 2024

Choose a reason for hiding this comment

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

We can't use gosu because all containers start with a static UID and any cap dropped. In this case 999. You can test the container with docker run -u 999 ... . Maybe you have to delete the volume first.
https://github.com/greenbone/automatix/blob/main/compose/dev/components/opensight/asset-management/compose.yaml#L14

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.

2 participants