Can't push migrations to Neon from a deno project (DNS error?)

I'm trying to push some migrations to a Neon database. Config for reference:
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dbCredentials: {
url: Deno.env.get("POSTGRES_DEFAULT_CONNSTRING") as string
},
dialect: "postgresql",
schema: "db/schema/*",
out: "db/migrations",
});
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dbCredentials: {
url: Deno.env.get("POSTGRES_DEFAULT_CONNSTRING") as string
},
dialect: "postgresql",
schema: "db/schema/*",
out: "db/migrations",
});
Running deno run --env -A --node-modules-dir npm:drizzle-kit generate --config ./db/drizzle.config.ts works fine and generates migrations. The following also works:
import { Pool } from 'npm:@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-serverless';

const pool = new Pool({
connectionString: Deno.env.get("POSTGRES_DEFAULT_CONNSTRING") as string
});

const db = drizzle({
client: pool
})

const res = await db.execute('select 1');
console.log(res)

export default db;
import { Pool } from 'npm:@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-serverless';

const pool = new Pool({
connectionString: Deno.env.get("POSTGRES_DEFAULT_CONNSTRING") as string
});

const db = drizzle({
client: pool
})

const res = await db.execute('select 1');
console.log(res)

export default db;
However, trying to actually push the migrations gives me this:
Reading config file '[***]/api/db/drizzle.config.ts'
Using 'pg' driver for database querying
[⣷] applying migrations...Error: getaddrinfo ENOTFOUND [***].eu-west-2.aws.neon.tech
at file:///[***]/api/node_modules/.deno/[email protected]/node_modules/pg-pool/index.js:45:11
at Object.runMicrotasks (ext:core/01_core.js:692:26)
at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
at eventLoopTick (ext:core/01_core.js:185:21)
at async PgDialect.migrate (file:///[***]/api/node_modules/.deno/[email protected]/node_modules/drizzle-orm/pg-core/dialect.js:54:5)
at async migrate (file:///[***]/api/node_modules/.deno/[email protected]/node_modules/drizzle-orm/node-postgres/migrator.js:4:3) {
errno: -3007,
code: "ENOTFOUND",
syscall: "getaddrinfo",
hostname: "[***].eu-west-2.aws.neon.tech"
}

[***] - redacted
Reading config file '[***]/api/db/drizzle.config.ts'
Using 'pg' driver for database querying
[⣷] applying migrations...Error: getaddrinfo ENOTFOUND [***].eu-west-2.aws.neon.tech
at file:///[***]/api/node_modules/.deno/[email protected]/node_modules/pg-pool/index.js:45:11
at Object.runMicrotasks (ext:core/01_core.js:692:26)
at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
at eventLoopTick (ext:core/01_core.js:185:21)
at async PgDialect.migrate (file:///[***]/api/node_modules/.deno/[email protected]/node_modules/drizzle-orm/pg-core/dialect.js:54:5)
at async migrate (file:///[***]/api/node_modules/.deno/[email protected]/node_modules/drizzle-orm/node-postgres/migrator.js:4:3) {
errno: -3007,
code: "ENOTFOUND",
syscall: "getaddrinfo",
hostname: "[***].eu-west-2.aws.neon.tech"
}

[***] - redacted
anyone have any idea why this is happening? 😩 btw, I have tried both the pooled and non-pooled connection strings.
1 Reply
chrisyalamov
chrisyalamovOP2w ago
Found the answer, posting in case anyone else runs into this: drizzle-kit push and migrate don't seem to use a driver that is compatible with Neon, so you need to write your own script for applying migrations. See this article: https://neon.tech/docs/guides/drizzle-migrations#run-the-migration
Neon
Schema migration with Neon Postgres and Drizzle ORM - Neon Docs
Drizzle is a TypeScript first ORM that connects to all major databases and works across most Javascript runtimes. It provides a simple way to define database schemas and queries in an SQL like dialect...

Did you find this page helpful?