Repository navigation
Windows fix - #435
Windows fix#435DracFiendMG wants to merge 2 commits into
Conversation
…d cross-env dependency
|
There was a problem hiding this comment.
Pull request overview
Fixes Windows startup for the SQLite-backed (npx @truefoundry/trueforge) flow by changing how SQLite migration modules are loaded so Node’s ESM loader receives a valid file:// specifier on Windows.
Changes:
- Replaces Kysely’s
FileMigrationProviderusage for SQLite with a customFileUrlMigrationProvider. - Adds
FileUrlMigrationProviderto load migration modules via dynamicimport()(with Windows-specific file URL handling).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/trueforge/src/db/migrateSqlite.ts | Switches SQLite migrator to the new custom migration provider. |
| packages/trueforge/src/db/fileUrlMigrationProvider.ts | Introduces a migration provider that reads the migrations directory and imports migration modules dynamically. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const specifier = process.platform === 'win32' ? pathToFileURL(fullPath).href : fullPath; | ||
|
|
||
| const migration = (await import(specifier)) as Migration; | ||
| const key = file.substring(0, file.lastIndexOf('.')); | ||
| migrations[key] = migration; |
| export async function migrateSqliteToLatest(db: Kysely<Database>): Promise<void> { | ||
| const migrator = new Migrator({ | ||
| db, | ||
| provider: new FileMigrationProvider({ | ||
| fs, | ||
| path, | ||
| migrationFolder: path.join(import.meta.dirname, 'sqlite', 'migrations'), | ||
| }), | ||
| provider: new FileUrlMigrationProvider(path.join(import.meta.dirname, 'sqlite', 'migrations')), | ||
| }); |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4299bc6. Configure here.
|
|
||
| return migrations; | ||
| } | ||
| } |
There was a problem hiding this comment.
Redundant migration provider
Medium Severity
FileUrlMigrationProvider reimplements Kysely's FileMigrationProvider, but that class already accepts a custom import hook (since 0.29.0; this package uses ^0.29.4) intended for the Windows file:// case. The copy also skips Kysely's default-export unwrap and isMigration checks, so behavior can drift from the built-in provider.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4299bc6. Configure here.
|
|
||
| const specifier = process.platform === 'win32' ? pathToFileURL(fullPath).href : fullPath; | ||
|
|
||
| const migration = (await import(specifier)) as Migration; |
There was a problem hiding this comment.
Disallowed type assertion
Low Severity
The dynamic import result is forced to Migration with as Migration, which violates the project rule that bans as T / similar assertions to silence typing. A sound approach uses a type guard (as Kysely's isMigration does) or a corrected contract instead of asserting the module namespace.
Triggered by project rule: TrueForge review rules
Reviewed by Cursor Bugbot for commit 4299bc6. Configure here.
|
|
||
| return migrations; | ||
| } | ||
| } |
There was a problem hiding this comment.
Missing package changeset
Low Severity
Non-blocking: this ships in @truefoundry/trueforge but the PR adds no .changeset/*.md. Please run pnpm changeset and bump @truefoundry/trueforge.
Additional Locations (1)
Triggered by project rule: TrueForge review rules
Reviewed by Cursor Bugbot for commit 4299bc6. Configure here.
|
Much needed feature |
|
@DracFiendMG Thanks for your interest to contribute, we think #374 as in a more mergeable state and hence we would like the windows compatibility issue solved through that. You can look at other |


Summary
This PR fixes Issue #427
Closes #427
Changes
A small custom migration provider that imports migrations via a
file://URL on Windows.How was this tested?
Cloned, built and ran the repo locally and validated whether the behavior after the fix.

Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Low Risk
Small, SQLite-only change to how migration files are loaded; Postgres migration setup is unchanged.
Overview
Fixes SQLite startup on Windows where dynamic
import()of migration modules failed when given raw filesystem paths (Issue #427).migrateSqliteToLatestnow uses a customFileUrlMigrationProviderinstead of Kysely’sFileMigrationProvider. The provider still scanssqlite/migrationsfor.js/.tsfiles, but onwin32it loads each migration viapathToFileURL(...).href; on other platforms it keeps importing by path as before.Reviewed by Cursor Bugbot for commit 4299bc6. Bugbot is set up for automated code reviews on this repo. Configure here.