kysely-ctl
kysely-ctl copied to clipboard
required to install 'ws' to perform migrations from 'neondb'
I'm required to install the 'ws' dependency into my project in order to perform migration on an external 'neondb' connection
error message:
> kysely migrate:down
◐ Starting migration down
✖ Migration failed with Error: All attempts to open a WebSocket to connect to the database failed. Please refer to https://github.com/neondatabase/serverless/blob/main/CONFIG.md#websocketconstructor-typeof-websocket--undefined. Details: fetch failed
temporary fix:
import { Pool, neonConfig } from '@neondatabase/serverless'
import ws from 'ws'
neonConfig.webSocketConstructor = ws
const pool = new Pool({ connectionString: process.env.DB_ADDRESS })
export default defineConfig({
dialect: new PostgresDialect({ pool }),
migrations: {
migrationFolder: './src/lib/db/migrations',
},
})
expected result: not having to install an ws dependency since the connection to run the project works just fine:
import { Kysely, PostgresDialect } from 'kysely'
const pool = new Pool({ connectionString: process.env.DB_ADDRESS })
export const db = new Kysely<...>({
dialect: new PostgresDialect({ pool }),
})
running with previous migration-cli would work fine on this scenario.
we might be able to fix that by updating conditions on getDialect
?