drizzle-orm: [BUG]: drizzle-kit push:mysql throws error with only connectionString
What version of drizzle-orm are you using?
0.26.1
What version of drizzle-kit are you using?
0.18.1
Describe the Bug
When I try to migrate (push) my schema to my DB it throws an error Error: Either connectionStringorhost, port, etc. params be provided in config file.
drizzle.config.ts
import type { Config } from "drizzle-kit";
export default {
schema: "./db/schema/*",
out: "./db/drizzle",
connectionString: process.env["DATABASE_URL"],
} satisfies Config;
/db/index.ts
import { drizzle } from "drizzle-orm/planetscale-serverless";
import { connect } from "@planetscale/database";
// create the connection
const connection = connect({
url: process.env["DATABASE_URL"],
});
export const db = drizzle(connection);
However I specified the connectionString… Am I doing something wrong here?
Expected behavior
It should push to db if I declared connectionString
Environment & setup
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18
Hi all,
If you’re using NextJS, don’t forget to change the path in
dotenv.config({ path: 'your-env-path' }). It took me a while before I realised I had the variable stored in.env.localso I had to change mydrizzle.config.tsto:Additionally; you could create a ‘normal’
.envfile and put your credentials there anddotenvwould find them automatically as that’s it’s default path.if you do not want to use
dotenvpackage in Nextjs then use@next/env:I had this issue as well until I realized the same thing, the env variable was not being loaded.
Assuming your
drizzle.config.tsfile is located in the root directory like mine is, the way I was able to get the environment variable to load was by using thedotenvlibrary. I discovered this by looking at this example from the docs, where they are also usingdotenvto load the variable while having theirdrizzle.config.tsfile in the root directory.Hope this helps!
Ok, I just realized this was due to me/NextJS…
Since I was just running
drizzle-kit push:mysqlit didn’t load env variable… When replacing that with the actual string it works 👍However, does anyone know how this could be fixed to work with .env normally?
someone found a solution for this on SvelteKit?
Anyone having difficultly connecting with local mysql?
Like my string is:
mysql://username:password@localhost:3306/masterdbI can easily connect the same in terminal and tableplus but here it gives me this error:
code: 'ERR_INVALID_URL'This came after I solved the error mentioned in this issue.
Hi, i still have an error : “No config path provided, using default 'drizzle.config.ts” despite i followed all thread’s recommandations …
drizzle.config.ts
db.ts
all my files are in root directory folder and i’m using supabase as DB
Thanks for your help
In case anyone else runs into this issue. I got the same
No config path provided, using default 'drizzle.config.ts'error by usingdrizzle-kit generate:pgwhen I should have been usingdrizzle-kit generate:sqlite.ok, got same problem and just realize
connectionStringonly exist in pg driver, i use mysql2 driver so i useuriMy problem persist if I still have values in the .env file. When removing the values, I can see the .env.local are being used. Still not ideal for me…
Hi, Did you solve it? I’ve tried all methods of this thread and none worked.
No config path provided, using default pathError: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a stringAccessing envs depends on your environment. In my case running anything from within my app (SvelteKit) get access to env via the special helper
$envin SvelteKit. When I run migrations outside of my app via a local node script, it’sprocess.env.SOME_VAR. So you need to check in which env (app-wise but also if local or remote/production) your script is really running and then, google how to get the env vars there. So, it’s often more complicated than expected, mind to close that issue since it’s not one with drizzle?