Skip to content

Fix migration completion checks - #201

Merged
nullure merged 1 commit into
CaviraOSS:mainfrom
mameikagou:agent/fix-migration-completion-checks
Aug 13, 2026
Merged

Fix migration completion checks#201
nullure merged 1 commit into
CaviraOSS:mainfrom
mameikagou:agent/fix-migration-completion-checks

Conversation

@mameikagou

Copy link
Copy Markdown
Contributor

What changed

  • Give each schema migration its own completion column (user_id for 1.2.0 and project_id for 1.3.0).
  • Check the real schema even when schema_version claims the migration already ran, so databases incorrectly marked as 1.3.0 can self-repair.
  • Apply the same completion logic to SQLite and PostgreSQL migrations.
  • Add SQLite regression coverage for the corrupted 1.3.0 state and repeated, idempotent execution.

Why

The migration runner used memories.user_id as the applied check for every migration. Once 1.2.0 added that column, 1.3.0 was skipped and the missing project_id columns were still recorded as applied.

The version record alone cannot repair databases that already hit this bug, so the runner now also checks the migration-specific completion column.

Impact

Existing databases marked as 1.3.0 but missing project isolation columns are repaired on the next migration run. Already-correct databases remain unchanged.

Validation

  • npm run typecheck
  • npx vitest run tests/migrate.test.ts --maxWorkers=1 --no-file-parallelism
  • npm test (42 tests passed)

Closes #196

@nullure
nullure marked this pull request as ready for review August 13, 2026 13:33

@nullure nullure left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nullure
nullure merged commit 9dc9b44 into CaviraOSS:main Aug 13, 2026
3 checks passed
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.

sqlite migration 1.3.0 (project_id) never runs — 'already applied' check uses wrong column

2 participants