Skip to content

Remove runtime DB initialization; require explicit Alembic migrations - #44

Merged
AlexKitipov merged 1 commit into
mainfrom
codex/remove-runtime-create_all-and-require-migrations
Jun 9, 2026
Merged

Remove runtime DB initialization; require explicit Alembic migrations#44
AlexKitipov merged 1 commit into
mainfrom
codex/remove-runtime-create_all-and-require-migrations

Conversation

@AlexKitipov

Copy link
Copy Markdown
Owner

Motivation

  • Prevent the application from creating or modifying the database schema at runtime so production schema changes are applied only via migrations.
  • Make schema migrations an explicit step in deployment and container workflows to avoid accidental in-place schema drift.

Description

  • Removed runtime database initialization from the FastAPI startup path by deleting the init_db import and the lifespan hook in app/main.py, so the app no longer calls create_all on startup.
  • Added scripts/migrate.sh which runs alembic upgrade head and copied the scripts/ directory into the Docker image via Dockerfile so migrations can be run from the image.
  • Added a migrate service to docker-compose.yml (profile migrations) that runs the migration helper as a separate step, and removed the implicit alembic upgrade head from the backend startup command.
  • Updated deploy.sh and README.md to ensure .env is created before migrations and to run migrations explicitly (./scripts/migrate.sh / alembic upgrade head) before enabling/starting the service or bringing up the API.

Testing

  • Ran python -m pytest and all tests passed (8 passed).
  • Ran git diff --check which reported no issues.
  • Performed static shell checks with sh -n scripts/migrate.sh deploy.sh which succeeded without syntax errors.
  • Attempted docker compose config validation but it could not be run in this environment because Docker is not installed.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00be28c283

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread deploy.sh
@AlexKitipov
AlexKitipov merged commit 78754a8 into main Jun 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant