Skip to content

[INFRA 5] Adopt Alembic for database schema migrations #158

Description

@m-khan-97

Objective

Replace hand-rolled DDL with a real migration framework so schema changes are versioned, ordered, and reversible.

Current state

  • Migrations are CREATE TABLE IF NOT EXISTS / ALTER TABLE statements embedded in api/models/finding.py (run_migrations), executed on every boot by startup.sh and create_app()
  • No migration history table, no ordering guarantees, no rollback, no way to review a schema diff in a PR

Scope

  • Introduce Alembic with a baseline migration capturing the current production schema
  • Move all DDL out of DatabaseManager; it keeps only queries
  • alembic upgrade head runs as the release/startup step (startup.sh and compose)
  • Contributor docs: how to add a migration alongside a model change
  • Verify baseline is a no-op against the existing Render database (stamp, don't recreate)

Out of scope

Acceptance criteria

  • Fresh database reaches current schema via Alembic only
  • Existing production DB is stamped and upgrades cleanly with zero data change
  • run_migrations ad-hoc DDL removed
  • CI passes, base branch dev

Category

Infrastructure / Database

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestinfraInfrastructure, CI/CD, deployment, and platform engineeringpriority: mediumShould be fixed soon but not blocking

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
🔨 In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions