Skip to content

[Backend][Tech-debt] Two competing migration systems with inconsistent env flags #462

Description

@Penielka

Overview

The backend contains two independent database migration mechanisms:

  1. MigrationRunner + createPool driven by AUTO_RUN_MIGRATIONS (defaults to running, checks DATABASE_URL)
  2. Migrator driven by AUTO_MIGRATE (runs only when set to 'true')

Both run at startup with different triggering semantics and different defaults, so which migrations actually run depends on which env vars happen to be set. This is a recipe for schema drift between environments.

Evidence

  • backend/src/index.tsMigrationRunner/autoMigrate under AUTO_RUN_MIGRATIONS
  • backend/src/index.tsMigrator/migrator.up() under AUTO_MIGRATE

Acceptance Criteria

  • Consolidate onto a single migration runner and a single env flag
  • Document the intended startup migration behavior in .env.example
  • Add tests covering both "migrate on boot" and "skip migrations" paths

Files to Modify

  • backend/src/index.ts
  • backend/src/utils/migrate.ts
  • .env.example

Priority: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions