fix: wire runMigrations() into startup before initDatabase() #41

Merged
jason merged 1 commits from fix/wire-migrations-to-startup into master 2026-03-10 14:28:20 -05:00
Owner

Problem

migrations.js existed but was never called from server/index.js. Only initDatabase() was invoked on startup, meaning all migrations (001, 002, 003) were silently skipped on every container start — leaving any existing breedr.db with its original schema intact.

Fix

  • Import runMigrations from ./db/migrations in server/index.js
  • Call runMigrations(DB_PATH) before initDatabase() so schema is correct before any routes open connections
  • If migrations throw, server aborts startup with process.exit(1) rather than silently running with a broken schema

After merging

Rebuild and restart the container. You should see Migration 003 output in the logs and schema_version will be populated. The health_records CHECK constraint will be removed automatically.

## Problem `migrations.js` existed but was never called from `server/index.js`. Only `initDatabase()` was invoked on startup, meaning all migrations (001, 002, 003) were silently skipped on every container start — leaving any existing `breedr.db` with its original schema intact. ## Fix - Import `runMigrations` from `./db/migrations` in `server/index.js` - Call `runMigrations(DB_PATH)` **before** `initDatabase()` so schema is correct before any routes open connections - If migrations throw, server aborts startup with `process.exit(1)` rather than silently running with a broken schema ## After merging Rebuild and restart the container. You should see Migration 003 output in the logs and `schema_version` will be populated. The `health_records` CHECK constraint will be removed automatically.
jason added 1 commit 2026-03-10 14:24:49 -05:00
jason merged commit d1b02cb735 into master 2026-03-10 14:28:20 -05:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jason/breedr#41