Skip to content

fix(core): commit generated migration for session directory index - #240

Open
alltomatos wants to merge 4 commits into
devfrom
fix/session-directory-index-migration
Open

alltomatos wants to merge 4 commits into
devfrom
fix/session-directory-index-migration

Conversation

@alltomatos

Copy link
Copy Markdown
Owner

Issue for this PR

Closes #239

Type of change

  • Bug fix

What does this PR do?

unit (linux) and unit (windows) are currently red on dev itself, blocking CI on every open PR (including #234 and #237) from test/database-migration.test.ts > "declared schema has no ungenerated migrations".

Root cause: perf(core): add composite index on session(directory, time_created, id) (closes #229) (commit 5372b2ed3f) added an index declaration to packages/core/src/session/sql.ts but never ran the migration generator, so the declared Drizzle schema and the committed migration/snapshot diverged.

Fix: ran bun script/migration.ts from packages/core (the tool the check's own error message points to) — no manual edits to any generated file. This adds the missing migration file and regenerates schema.json, schema.gen.ts, and migration.gen.ts.

How did you verify your code works?

  • bun script/migration.ts --check from packages/core now exits 0 (was exiting 1 before this fix, reproduced against dev's actual head).
  • bun test test/database-migration.test.ts → 16 pass, 0 fail (was 1 fail before the fix).

Screenshots / recordings

N/A — generated migration/schema files only, no behavior change beyond what commit 5372b2e already declared.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

🤖 Generated with Claude Code

https://claude.ai/code/session_015KrFrdVEmx7apnofWUViJw


Generated by Claude Code

alltomatos and others added 4 commits September 14, 2026 23:31
perf(core) commit 5372b2e added a composite index declaration
(session_directory_time_created_id_idx on directory, time_created, id)
to packages/core/src/session/sql.ts but never ran the migration
generator, so the declared schema and the committed migration/snapshot
diverged. unit (linux)/unit (windows) on dev have been red ever since
(DatabaseMigration > declared schema has no ungenerated migrations),
blocking CI on every PR regardless of what it touches.

Ran `bun script/migration.ts` from packages/core (the tool the check's
own error message points to) to generate the missing migration file
and regenerate schema.json/schema.gen.ts/migration.gen.ts -- no manual
edits to any generated file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015KrFrdVEmx7apnofWUViJw

Copy link
Copy Markdown
Owner Author

unit (linux) still shows red here, but @opencode-ai/core#test (what this PR fixes) now passes cleanly — "Tasks: 6 successful, 9 total ... Failed: @opencode-ai/app#test". The remaining failure is the other pre-existing dev bug (formatMinutes locale, stats-controller.test.ts), already fixed separately in #237. This PR branched from dev before #237 merged, so it still carries that unrelated bug. Once #237 merges, rebasing/merging dev into this branch (or just merging this PR after #237) will clear it — nothing further to do on this PR itself.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

e2e (linux) failure here is also the same pre-existing dev regression tracked in #238 (legacy-new-session.spec.ts:9 and session-timeline-projection.spec.ts:131) — unrelated to this PR's migration fix.


Generated by Claude Code

alltomatos added a commit that referenced this pull request Sep 15, 2026
…ened first)

My earlier commit generated a migration with a different random id for
the same session_directory_time_created_id_idx index that #240 (opened
~10h earlier) already added. Removing mine and using #240's exact
migration/schema files instead, so this PR's ported fix aligns with
whichever one actually merges into dev.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SHQKcGH7ayRe8UHJ9CAPQJ
alltomatos added a commit that referenced this pull request Sep 15, 2026
alltomatos added a commit that referenced this pull request Sep 15, 2026
alltomatos added a commit that referenced this pull request Sep 15, 2026
Use the same schema id/prevIds as PR #240's session_directory_time_created_id_idx
migration to avoid two divergent migration histories for the same index.
alltomatos added a commit that referenced this pull request Sep 15, 2026
Previous commit had a transcription error (table: session instead of
table: todo) and a missing trailing newline vs PR #240's canonical file.
alltomatos added a commit that referenced this pull request Sep 15, 2026
…id_idx

Ported from #240 (not yet merged to dev) to unblock this PR's own CI —
same base-branch-wide failure documented on #241. No-ops once dev carries #240.
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.

fix(core): commit generated migration for session directory index

1 participant