drizzle + turso config

im not able to migrate my schema using drizzle + turso drizzle.config.ts
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config();

export default {
schema: "./src/db/schema",
out: "./src/db/migrations",
driver: "turso",
dialect: "sqlite",
dbCredentials: {
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
},
} satisfies Config;
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config();

export default {
schema: "./src/db/schema",
out: "./src/db/migrations",
driver: "turso",
dialect: "sqlite",
dbCredentials: {
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
},
} satisfies Config;
No description
2 Replies
ManKid
ManKid7mo ago
same issue here not sure if you found a fix, but I just got mine working. It comes from 'dotenv' not being able to read .env.local heres some updated code:
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config({path: `.env.local`, override: true});

export default {
schema: "./drizzle/schema.ts",
out: "./drizzle/migrations",
driver: "turso",
dbCredentials: {
url: process.env.TURSO_DATABASE_URL as string,
authToken: process.env.TURSO_AUTH_TOKEN as string,
},
dialect: 'sqlite'
} satisfies Config;
import type { Config } from "drizzle-kit";
import * as dotenv from "dotenv";
dotenv.config({path: `.env.local`, override: true});

export default {
schema: "./drizzle/schema.ts",
out: "./drizzle/migrations",
driver: "turso",
dbCredentials: {
url: process.env.TURSO_DATABASE_URL as string,
authToken: process.env.TURSO_AUTH_TOKEN as string,
},
dialect: 'sqlite'
} satisfies Config;
ManKid
ManKid7mo ago
I did also just create a PR to add a snippet for configuring named environment files. https://github.com/tursodatabase/turso-docs/pull/196
GitHub
Named Environment File Causes Drizzle-Kit Studio to throw an error....
Minor update to address errors faced by some users copy pasting the drizzle.config.ts snippet directly while using a named environment file. It's currently 2am and it tripped me up for long eno...
Want results from more Discord servers?
Add your server