Closed MuhammadBilal1234 closed 1 year ago
getting same bug. all same except i am using drizzle-orm 0.27.0
EDIT: seems it was due to the DATABASE_URL being missing in the .env though a better error message might have better helped identify the issue.
Same issue here. Just like @John-Dennehy using drizzle-orm 0.27.0. However, 'DATABASE_URL' is present in my .env file, but still getting that error
Ok, stupid mistake, forgot to actually read the .env file 🤦♂️
@MuhammadBilal1234 From the code that you provided I see you made the same mistake. To fix that, place these lines under the import statement in your 'drizzle.config.ts' file (make sure to point to the correct .env file. For me that is '.env.local', for you it can be just '.env')
import dotenv from 'dotenv'
dotenv.config({ path: '.env.local' })
I'm facing a same error but I'm using user
and password
instead
const username = process.env.DATABASE_USERNAME;
const password = process.env.DATABASE_PASSWORD;
if (!username || !password) {
throw new Error('Please set DATABASE_USERNAME and DATABASE_PASSWORD');
}
/** @satisfies { import("drizzle-kit").Config } */
export default {
schema: './schema/*.@(js|ts)',
out: './drizzle',
driver: 'mysql2',
dbCredentials: {
host: 'aws.connect.psdb.cloud',
user: username,
password
}
};
And I got the same error
Invalid input "mysql2" is not a valid driver. Available drivers: "pg", "mysql2", "better-sqlite", "libsql", "turso". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference
ELIFECYCLE Command failed with exit code 1.
I confirmed that username and password are read.
I was suffering with same error for pretty long, and the answer was so silly: I had accidentally moved my .env
file from root
to /src
. Hope, that might be helpful for someone
i also got this silly error when i changed .env
file to .env.local
i was using:
import 'dotenv/config'
& it was working when i had an .env
now i have to use:
import * as dotenv from 'dotenv'
dotenv.config({ path: '.env.local' })
my question is do i need to change the path
during production?
What version of
drizzle-orm
are you using?^0.26.5
What version of
drizzle-kit
are you using?^0.19.3
Describe the Bug
import type { Config } from "drizzle-kit";
export default { schema: "./src/db/schema/schema.ts", out: "./src/db/drizzle", driver: "mysql2", dbCredentials: { connectionString: process.env.DATABASE_URL!, }, } satisfies Config;
Above is my config file and following is main file for db
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { connect } from "@planetscale/database";
import { migrate } from "drizzle-orm/planetscale-serverless/migrator";
import * as schema from "./schema/schema";
const connection = connect({ url: process.env["DATABASE_URL"], });
export const db = drizzle(connection, { schema }); migrate(db, { migrationsFolder: "./src/db/drizzle" })
Expected behavior
When I try to run
pnpm drizzle-kit studio
I get this error."mysql2" is not a valid driver. Available drivers: "pg", "mysql2", "better-sqlite", "libsql", "turso".
No response
Environment & setup
No response