Skip to content

Fix production migration packaging - #200

Merged
haasonsaas merged 1 commit into
mainfrom
jh/prod-migrations-packaging-20260427
Apr 27, 2026
Merged

haasonsaas merged 1 commit into
mainfrom
jh/prod-migrations-packaging-20260427

Conversation

@haasonsaas

@haasonsaas haasonsaas commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • ship database migrations into dist and the runtime Docker image so startup can find the Drizzle journal
  • reconcile legacy databases only when the full 0000_initial baseline exists, with audit_hash_cache as the explicit 0007 repair exception
  • add a repair migration for missing audit_hash_cache and tests that guard migration packaging plus baseline detection

Validation

  • ./node_modules/.bin/biome check src/db/migrate.ts test/db/migrate-legacy-reconciliation.test.ts test/db/migration-files.test.ts test/db/hosted-session-storage.integration.test.ts
  • node ./scripts/run-vitest.js --run test/db/migrate-legacy-reconciliation.test.ts test/db/migration-files.test.ts test/db/hosted-session-storage.integration.test.ts test/web-health.test.ts test/server/health.test.ts
  • PATH=/Users/jonathanhaas/.bun/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/opt/homebrew/bin:/Users/jonathanhaas/.dotfiles/bin:/Users/jonathanhaas/.dotfiles/scripts:/Users/jonathanhaas/.dotfiles/scripts/bin:/Users/jonathanhaas/.codex/tmp/arg0/codex-arg0c51p5M:/etc/profiles/per-user/jonathanhaas/bin:/opt/homebrew/opt/node@22/bin:/nix/var/nix/profiles/default/bin:/Users/jonathanhaas/.nix-profile/bin:/Users/jonathanhaas/.local/bin:/Users/jonathanhaas/bin:/run/current-system/sw/bin:/Users/jonathanhaas/.npm-global/bin:/Users/jonathanhaas/.config/zsh/plugins/fast-syntax-highlighting:/Users/jonathanhaas/.config/zsh/plugins/zsh-autosuggestions:/Users/jonathanhaas/.config/zsh/plugins/zsh-completions:/Users/jonathanhaas/.config/zsh/plugins/fzf-tab:/Users/jonathanhaas/.config/zsh/plugins/zsh-you-should-use:/Applications/Ghostty.app/Contents/MacOS bun run --cwd packages/contracts build
  • PATH=/Users/jonathanhaas/.bun/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/opt/homebrew/bin:/Users/jonathanhaas/.dotfiles/bin:/Users/jonathanhaas/.dotfiles/scripts:/Users/jonathanhaas/.dotfiles/scripts/bin:/Users/jonathanhaas/.codex/tmp/arg0/codex-arg0c51p5M:/etc/profiles/per-user/jonathanhaas/bin:/opt/homebrew/opt/node@22/bin:/nix/var/nix/profiles/default/bin:/Users/jonathanhaas/.nix-profile/bin:/Users/jonathanhaas/.local/bin:/Users/jonathanhaas/bin:/run/current-system/sw/bin:/Users/jonathanhaas/.npm-global/bin:/Users/jonathanhaas/.config/zsh/plugins/fast-syntax-highlighting:/Users/jonathanhaas/.config/zsh/plugins/zsh-autosuggestions:/Users/jonathanhaas/.config/zsh/plugins/zsh-completions:/Users/jonathanhaas/.config/zsh/plugins/fzf-tab:/Users/jonathanhaas/.config/zsh/plugins/zsh-you-should-use:/Applications/Ghostty.app/Contents/MacOS bun run --cwd packages/tui build
  • ./node_modules/.bin/tsc -p tsconfig.build.json --noEmit --pretty false

Internal source PRs: evalops/maestro-internal#1513, evalops/maestro-internal#1514

@cursor

cursor Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches database migration execution and introduces legacy-schema detection/auto-marking, which can affect production schema state if markers are incorrect. Adds a new migration and changes packaging paths, so failures would surface at startup/runtime rather than build time.

Overview
Fixes production migration discovery by shipping Drizzle SQL migrations/journal into dist and the runtime Docker image, wiring this into the build script via a new copy-db-migrations.js helper.

Enhances src/db/migrate.ts to reconcile legacy databases by detecting an existing 0000_initial baseline (via schema markers) and marking it applied instead of re-running it; it hard-fails if it detects a partial baseline.

Adds migration 0007_reconcile_legacy_audit_hash_cache to repair missing audit_hash_cache (and its FK when possible), updates the migration journal, and extends/introduces tests to lock in migration packaging and the new reconciliation behavior (including updating expected migration counts).

Reviewed by Cursor Bugbot for commit 578215b. Bugbot is set up for automated code reviews on this repo. Configure here.

@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: 38f2d7b1a3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/db/migrate.ts Resolved
@haasonsaas
haasonsaas force-pushed the jh/prod-migrations-packaging-20260427 branch from 38f2d7b to 578215b Compare April 27, 2026 07:01
@haasonsaas
haasonsaas merged commit be6be4e into main Apr 27, 2026
12 checks passed
@haasonsaas
haasonsaas deleted the jh/prod-migrations-packaging-20260427 branch April 27, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant