Closed mmikhan closed 1 week ago
This is happening for me as well. "drizzle-orm": "^0.34.1", "pg": "^8.13.0", "drizzle-kit": "^0.26.0"
My drizzle.config.ts file looks like this:
`import * as dotenv from "dotenv"; import { defineConfig } from "drizzle-kit";
// Load environment variables dotenv.config();
// Determine the current environment const isDevelopment = process.env.NODE_ENV !== "production";
// Define required environment variables const requiredEnvVars = [ "DATABASE_HOST", "DATABASE_PORT", "DATABASE_USERNAME", "DATABASE_PASSWORD", isDevelopment ? "DATABASE_DB_DEV" : "DATABASE_DB_PROD", ];
// Check if environment variables are set and create a typed object
const envVars = requiredEnvVars.reduce((acc, key) => {
const value = process.env[key];
if (value === undefined) {
throw new Error(Missing required environment variable: ${key}
);
}
return { ...acc, [key]: value };
}, {} as Record<string, string>);
// Parse the port to ensure it's a number const port = parseInt(envVars.DATABASE_PORT, 10); if (isNaN(port)) { throw new Error("DATABASE_PORT must be a valid number"); }
export default defineConfig({ schema: "./src/**/schema.ts", out: "./src/app/core/drizzle/migrations", dialect: "postgresql", dbCredentials: { host: envVars.DATABASE_HOST, port: port, database: isDevelopment ? envVars.DATABASE_DB_DEV : envVars.DATABASE_DB_PROD, user: envVars.DATABASE_USERNAME, password: envVars.DATABASE_PASSWORD, }, verbose: isDevelopment, strict: true, });`
please install both orm and kit packages to the latest version
What version of
drizzle-orm
are you using?0.34.1
What version of
drizzle-kit
are you using?0.26.0
Describe the Bug
Running
pnpm drizzle-kit generate
shows the following error in the drizzle-kit v0.26.0 that was released recently but downgrading to v0.25.0 works fine.Expected behavior
pnpm drizzle-kit generate
generates the schemaEnvironment & setup
Reproducible in a fresh Next.js app. For your convenience, I have created one for you here: https://github.com/mmikhan/ispgviewisnotafunction. Clone the repo and run the
pnpm drizzle-kit generate
command