[BUG]: drizzle-kit introspect fails on required param that is defined
What version of drizzle-orm are you using?
0.32.1
What version of drizzle-kit are you using?
0.23.1
Describe the Bug
drizzle-kit introspect stops introspection for required param, even though it is defined.
Affected version 0.23.1
Working local version: 0.22.8 (did not test other versions)
introspect output
$ npx drizzle-kit introspect
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/test/project/test/drizzle.config.ts'
Error Please provide required params:
[✓] dialect: 'postgresql'
config;
$ bat drizzle.config.ts
│ File: /home/test/project/test/drizzle.config.ts
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ import 'dotenv/config';
2 │ import { defineConfig } from 'drizzle-kit';
3 │
4 │ export default defineConfig({
5 │ dialect: 'postgresql',
6 │ out: './src/drizzle',
7 │ schema: './src/drizzle/schema.ts',
8 │ dbCredentials: {
9 │ host: process.env.DB_HOST ?? '',
10 │ port: Number(process.env.DB_PORT ?? 0),
11 │ user: process.env.DB_USERNAME ?? '',
12 │ password: process.env.DB_PASSWORD ?? '',
13 │ database: process.env.DB_NAME ?? '',
14 │ ssl: false,
15 │ },
17 │ verbose: true,
19 │ strict: true,
20 │ });
env:
$ bat .env
12 │ # DB
13 │ DB_HOST=localhost
14 │ DB_PORT=5432
15 │ DB_USERNAME=test
16 │ DB_PASSWORD=test
17 │ DB_NAME=test
env is correct and tested, config works with 0.22.8
Expected behavior
Introspect running normally on version 0.22.8:
$ npx drizzle-kit introspect
drizzle-kit: v0.22.8
drizzle-orm: v0.32.1
No config path provided, using default path
Reading config file '/home/test/project/test/drizzle.config.ts
Pulling from ['public'] list of schemas
Using 'pg' driver for database querying
[✓] 8 tables fetched
[✓] 23 columns fetched
[✓] 0 enums fetched
[✓] 0 indexes fetched
[✓] 7 foreign keys fetched
[i] No SQL generated, you already have migrations in project
[✓] You schema file is ready ➜ src/drizzle/schema.ts 🚀
Environment & setup
OS: Ubuntu 22.04.4 LTS (Jammy Jellyfish)
PostgreSQL: 16.3 on x86_64-pc-linux-gnu
Same here just occurred few minutes ago with mysql.
× bunx drizzle-kit introspect
No config path provided, using default 'drizzle.config.ts'
Reading config file '.../packages/database/drizzle.config.ts'
Error Please provide required params:
[✓] dialect: 'mysql'
Just solved by downgrading to v0.22.8, as instructed. But indeed on v0.23.1 we got this error.
for reference, related files are followed.
drizzle.config.ts
> cat drizzle.config.ts
import { defineConfig } from "drizzle-kit";
import { connCredentials } from "./src/client";
export default defineConfig({
dialect: "mysql",
schema: "drizzle/schema/*",
out: "drizzle/migration",
dbCredentials: {
host: connCredentials.host,
port: connCredentials.port,
user: connCredentials.user,
password: connCredentials.password,
database: connCredentials.database,
},
strict: true,
});
client.ts
if (
!process.env.MYSQL_HOST ||
!process.env.MYSQL_USER ||
!process.env.MYSQL_PASSWORD ||
!process.env.MYSQL_DATABASE
) {
throw new Error(
"MYSQL_HOST or MYSQL_USER or MYSQL_PASSWORD or MYSQL_DATABASE is missing.",
);
}
export const connCredentials = {
host: process.env.MYSQL_HOST,
port: Number(process.env.MYSQL_PORT),
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
database: process.env.MYSQL_DATABASE,
};
// ...
.env
MYSQL_HOST="localhost"
MYSQL_PORT="3306"
MYSQL_USER="exampleUser"
MYSQL_PASSWORD="example"
MYSQL_DATABASE="exampleDb"
Environment & setup
OS: macOS Sequoia 15.0 arm64
MySQL: mariadb 15.1 Distrib 10.11.7-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
Same here. Just tried to pull the db schema but not working. This is critical. I need the introspect ^^
With
"drizzle-kit": "^0.22.0",
its working again.
Problems start with the versions after this one
I am having the same problem on EndeavourOS.
same error.
same problem on macOS 15 and drizzle-kit v0.23.1 solved with setting options via CLI but another error message shown:
TypeError: movedTables is not iterable
at applyPgSnapshotsDiff (/Users/cshif/.yarn/berry/cache/drizzle-kit-npm-0.23.1-c4c034d75c-10c0.zip/node_modules/drizzle-kit/bin.cjs:26289:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async introspectPostgres (/Users/cshif/.yarn/berry/cache/drizzle-kit-npm-0.23.1-c4c034d75c-10c0.zip/node_modules/drizzle-kit/bin.cjs:122649:42)
at async Object.handler (/Users/cshif/.yarn/berry/cache/drizzle-kit-npm-0.23.1-c4c034d75c-10c0.zip/node_modules/drizzle-kit/bin.cjs:129293:9)
at async rawCli (/Users/cshif/.yarn/berry/cache/drizzle-kit-npm-0.23.1-c4c034d75c-10c0.zip/node_modules/drizzle-kit/bin.cjs:127543:5)
at async run (/Users/cshif/.yarn/berry/cache/drizzle-kit-npm-0.23.1-c4c034d75c-10c0.zip/node_modules/drizzle-kit/bin.cjs:127551:5)
consequently, it doesn't generate any .sql in /drizzle
same error
Any updates on that one ?
I'm having the same using both CLI & Config file
Up
Same here. Just tried to pull the db schema but not working. This is critical. I need the introspect ^^
With
"drizzle-kit": "^0.22.0",its working again.
Problems start with the versions after this one
This worked for me! Thanks!
I also have the same problem
Downgrading to DrizzleKit Version 0.22.0 works
Got this issue today with ^0.24.0 so still an issue with the latest release. Like others, downgrading to ^0.22.0 did work.
Debugging the issue, it is caused by the validation of database from the pullParams Zod schema here: Its expecting an object with prefix in it.
preparePullConfig calls flattenPull before validating with the schema. flattenPull is putting dbCredentials properties at the root level, and database at the root is expecting a very different value to database inside dbCredentials.
As a secondary workaround to use the latest version, you can create a MySQL connection string and use that in dbCredentials for URL to avoid the validation issue:
dbCredentials: {
url: `mysql://${dbCredentials.user}:${dbCredentials.password}@${dbCredentials.host}:${dbCredentials.port}/${dbCredentials.database}`,
},
Same for me. "drizzle-kit": "^0.24.0" won't let me introspect :(
releasing fix in a few hours, sorry for late response!
This should be fixed in [email protected]
If you still encounter this issue, please reopen the ticket
I use sqlite and it still has problems.
import { defineConfig } from 'drizzle-kit'
export default defineConfig({
schema: './database/schema.ts',
out: './database/migrations',
dialect: 'sqlite',
driver: 'turso',
dbCredentials: {
url: process.env.TURSO_DATABASE_URL!,
authToken: process.env.TURSO_AUTH_TOKEN
},
verbose: true,
strict: true
})
No config path provided, using default 'drizzle.config.ts'
When I run drizzle-kit push I get the same error as reported above.
Seems like still the issue in "drizzle-kit": "^0.24.2", I am currently using it with bun. When i downgraded to "drizzle-kit": "^0.22.0", it started working correctly. Please review on it.
I encountered the same issue when using Drizzle with PgLite.
drizzle.config.ts
import "dotenv/config";
import type { Config } from "drizzle-kit";
export default {
schema: "./src/db/schema.ts",
out: "./src/db/drizzle",
dialect: "postgresql",
driver: "pglite",
dbCredentials: {
host: "localhost",
port: "5432",
password: "123",
database: "bookwise",
user: "bookwise",
ssl: "allow",
},
verbose: true,
} satisfies Config;
package.json
{
"scripts": {
"pglite:migration:generate": "drizzle-kit generate --config drizzle.config.ts",
"pglite:migration:apply": "drizzle-kit migrate --config drizzle.config.ts",
"pglite:migration:push": "drizzle-kit push --config drizzle.config.ts"
}
}
The pglite:migration:generate command works fine, but errors occur when attempting to pglite:migration:apply and pglite:migration:push.
Environment & setup
"@electric-sql/pglite": "^0.2.7",
"drizzle-orm": "^0.33.0",
"drizzle-kit": "^0.24.2",
I use sqlite and it still has problems.
import { defineConfig } from 'drizzle-kit' export default defineConfig({ schema: './database/schema.ts', out: './database/migrations', dialect: 'sqlite', driver: 'turso', dbCredentials: { url: process.env.TURSO_DATABASE_URL!, authToken: process.env.TURSO_AUTH_TOKEN }, verbose: true, strict: true })No config path provided, using default 'drizzle.config.ts'
I just encountered the same thing using Bun with Turso
I encountered the same issue
Project Details
Dependencies
{
"drizzle-orm": "^0.38.3",
"drizzle-kit": "^0.27.1",
"pg": "^8.13.1",
"postgres": "^3.4.5"
}
dev environment
- macOS
- Database: PostgreSQL (connected via DATABASE_URL)
- nodejs version: v22.1.0
- pnpm version: 8.15.4
drizzle.config.ts
import 'dotenv/config'; import { defineConfig } from 'drizzle-kit';
export default defineConfig({ out: './drizzle', schema: './src/lib/db/schema.ts', dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL!, }, });
Issue deatils
- Initially, running
pnpm dlx drizzle-kit introspect
produced the following error:
Error please install required packages: 'drizzle-orm'
- This occurred even though drizzle-orm was installed and listed in node_modules. Running pnpm list drizzle-orm confirmed the package was installed.
import * as dotenv from "dotenv"; import { resolve } from "path";
dotenv.config({ path: resolve(__dirname, ".env") });
import type { Config } from "drizzle-kit";
export default { schema: "./db/schema.ts", out: "./drizzle", dialect: "postgresql", dbCredentials: { url: process.env.DATABASE_URL as string, }, } satisfies Config;
this worked during for me, data pushed
I'm experiencing the same issue with "drizzle-kit": "^0.30.5".
✅ I was able to resolve it by reverting to "drizzle-kit": "^0.30.2".
Hope this helps others until the issue is fixed in a future release.
Just for others who might run into this, I encountered the issue because I didn't have the out property set in the config, using the mysql dialect:
Hello still running into this issue, any fixes?
import type {Config} from "drizzle-kit";
import {defineConfig} from "drizzle-kit";
import dotenv from "dotenv";
dotenv.config({
path: ".env.local",
});
const publicKey = "..."
const originalPublicKey = "..."
export default defineConfig({
schema: "./src/schema.ts",
out: "./drizzle",
dialect: "postgresql",
dbCredentials: {
ssl: {
ca: originalPublicKey,
rejectUnauthorized: false,
},
host: process.env.DB_HOST!,
port: parseInt(process.env.DB_PORT!),
user: process.env.DB_USER_NAME!,
password: process.env.DB_PASSWORD!,
database: process.env.DB_NAME!,
},
} satisfies Config);
drizzle-kit pull
No config path provided, using default 'drizzle.config.ts'
Reading config file '.../drizzle.config.ts'
Error Please provide required params:
[✓] dialect: 'postgresql'
drizzle-kit -v
drizzle-kit: v0.23.2
drizzle-orm: v0.32.2