Skip to content

feat(core): migration system (auto-run at boot, track in DB) #3218

@PierreBrisorgueil

Description

@PierreBrisorgueil

Description

Create a migration system that auto-runs pending migrations at app boot before app.listen().

Details

  • New MongoDB collection migrations tracking executed migrations (name, executedAt)
  • At boot: scan modules/*/migrations/*.js, compare with DB, run pending ones in order
  • Each migration exports up() (and optionally down())
  • Migrations are idempotent (safe to re-run if crashed mid-way)
  • Ordered by date prefix in filename (e.g. 2026-03-10-organizations-init.js)
  • Blocks app startup until all migrations complete

Acceptance criteria

  • Migration runner executes pending migrations at boot
  • Executed migrations are tracked in DB
  • Already-executed migrations are skipped
  • Migration failure prevents app from starting (with clear error log)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Critical — must be done firstphase:2-orgsPhase 2: Multi-tenancy & Organizations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions