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): env variable to skip migrations on startup #9069

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

mertalev
Copy link
Contributor

Description

Some deployment methods, like Portainer and TrueNAS SCALE, make it difficult to start the database without starting everything else as well. This makes it awkward to restore from a backup as the server will run migrations that then cause duplicate key violations, etc.

This PR adds an env variable to ease this process, skipping migrations to allow the admin to restore to a clean database.

Copy link

cloudflare-pages bot commented Apr 25, 2024

Deploying immich with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8d4d2b5
Status: ✅  Deploy successful!
Preview URL: https://a72a8ba7.immich.pages.dev
Branch Preview URL: https://feat-skip-migrations.immich.pages.dev

View logs

@mmomjian
Copy link
Contributor

mmomjian commented Apr 25, 2024

Ty. Can we update line 76 in backup and restore which states "When DB_URL is defined, the other database (DB_*) variables are ignored, with the exception of DB_VECTOR_EXTENSION." The same note is in the pre existing Postgres docs.

@mertalev
Copy link
Contributor Author

Ty. Can we update line 76 in backup and restore which states "When DB_URL is defined, the other database (DB_*) variables are ignored, with the exception of DB_VECTOR_EXTENSION." The same note is in the pre existing Postgres docs.

Good catch! I changed it to just list the relevant variables so it won't get outdated as more variables are added.

@mmomjian
Copy link
Contributor

mmomjian commented Apr 25, 2024

Ty. Can we update line 76 in backup and restore which states "When DB_URL is defined, the other database (DB_*) variables are ignored, with the exception of DB_VECTOR_EXTENSION." The same note is in the pre existing Postgres docs.

Good catch! I changed it to just list the relevant variables so it won't get outdated as more variables are added.

Ty! I misspoke its also on line 76 of env vars docs that also contains the same language. I like switching to explicitly saying which ones are ignored.


:::info

When `DB_URL` is defined, the other database (`DB_*`) variables are ignored, with the exception of `DB_VECTOR_EXTENSION`.
When `DB_URL` is defined, the `DB_HOSTNAME`, `DB_PORT`, `DB_USERNAME`, `DB_PASSWORD` and `DB_DATABASE_NAME` database variables are ignored.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ty!

@mertalev mertalev merged commit 466451a into main Apr 25, 2024
23 checks passed
@mertalev mertalev deleted the feat/skip-migrations branch April 25, 2024 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants