orchid-orm: Migrations don't work on Windows
I’m trying to use the new migration strategy introduced in 1.25 but it fails loading the ./db file:
import { rakeDb } from 'orchid-orm/migrations'
import { BaseTable } from './baseTable'
export const change = rakeDb(
{ databaseURL: process.env.DIRECT_URL },
{
baseTable: BaseTable,
snakeCase: true,
migrationsTable: 'migrations',
migrationsPath: './migrations',
dbPath: './db',
commands: {
async seed() {
const { seed } = await import('./seed')
await seed()
}
}
}
)
Running npm run db g crashes with:
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at new NodeError (node:internal/errors:405:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:138:11)
at defaultLoad (node:internal/modules/esm/load:89:3)
at nextLoad (node:internal/modules/esm/hooks:733:28)
at Z (file:///C:/Users/<redacted>/node_modules/tsx/dist/esm/index.mjs:2:1750)
at nextLoad (node:internal/modules/esm/hooks:733:28)
at Hooks.load (node:internal/modules/esm/hooks:377:26)
at MessagePort.handleMessage (node:internal/modules/esm/worker:168:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:778:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Node.js v20.5.0
db script is defined as tsx src/db/dbScript.ts
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 29 (11 by maintainers)
Amazing @romeerez you rock!
In progress, just want to share that Windows is so tough. It layed down broken after update for about a year on my machine, but luckly, I reinstalled it recently. So far I figured out how to enable developers mode, installed node.js. Now trying to install postgres and I’m a bit stuck with it. (upd: ranted of how difficult it is, but in fact I just clicked a wrong link so it’s fine).
Fireship yesterday posted a video about Windows vs Macos vs Linux for devs, and damn, what a big lier he is. Windows devs should realize and be proud of how many difficulties they have to overcome for what they’re doing compared to Mac and Linux users. Even disabling automatic update is such a challenge, so every time Windows is shutting down and updates things I’m praying that I won’t need to reinstall it again.
Maybe it’s easier when using WSL, but last time I tried to install WSL it was also a journey on itself, so much patience and dedication is needed. All those folks who claims things like “windows is for noobs” are so far form reality, developers on Windows are true heros who can fight back complexities that would make Mac/Linux users to give up and run away.