Skip to content

Apply database migrations when the API starts - #100

Merged
om986 merged 1 commit into
mainfrom
feat/serve-auto-migrate
Oct 14, 2026
Merged

om986 merged 1 commit into
mainfrom
feat/serve-auto-migrate

Conversation

@om986

@om986 om986 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • om serve applies pending migrations before it listens, so Docker Compose and a first om serve create the schema without a separate ./om migrate.
  • Every start applies only files that are not already in schema_migrations. OM_AUTO_MIGRATE=false (Helm api.autoMigrate) leaves schema changes to an explicit om migrate. The Helm init container still runs om migrate first.
  • A Postgres advisory lock covers concurrent serve and init-container runs. Each file and its version row commit together.

om scan and the other CLI commands still do not migrate. Use om migrate when Postgres is up and the API is not.

Test plan

  • docker compose up -d on an empty volume, then open the console without running om migrate
  • Restart the API and confirm the log says database schema is current
  • OM_AUTO_MIGRATE=false leaves a fresh database uninitialized until om migrate
  • ./om migrate on an already-migrated database prints Database schema is current.
  • Helm render shows OM_AUTO_MIGRATE set to "true" and the migrate init container is still present

Made with Cursor

Docker Compose and a bare om serve previously came up with an empty schema, so the console asked for a manual om migrate even though the image already contains the SQL. Pending files now apply before listen, and an explicit migrate remains for Postgres-only use.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: OpenSourceOM/core/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b6194d49-554e-4ea3-bb49-32e4876499f0
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@om986
om986 merged commit f82ee48 into main Oct 14, 2026
7 checks passed
@om986
om986 deleted the feat/serve-auto-migrate branch October 14, 2026 22:43
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.

1 participant