.env file contents for local dev testing

Hi, I'd like to get the tests working on a local dev environment. Does anyone have a working .env file for local testing and development they could share with me? I found the example .env file for the integration tests - however, the tests don't pass with the contents of that file alone (on the freshly checked out main main). I have searched through the documentation and through the integration test directories for hints but I have not found anything that is of use. I could go through each integration test and slowly build the config but I'm hoping I don't need to spend that effort.
3 Replies
Techpure
Techpure4d ago
@Azman
# Postgres (default port 5432)
DATABASE_URL=postgres://postgresuser:password@127.0.0.1:5432/name_of_your_database

# Admin token (replace with a long random string in your real .env)
ADMIN_TOKEN=change_me_to_a_long_random_admin_token
# Postgres (default port 5432)
DATABASE_URL=postgres://postgresuser:password@127.0.0.1:5432/name_of_your_database

# Admin token (replace with a long random string in your real .env)
ADMIN_TOKEN=change_me_to_a_long_random_admin_token
JustWayne
JustWayne4d ago
I am using Cloudflare so my env vars are in a .dev.vars file during development and so I do something like this for my drizzle-config file:
/**
* @file Configuration for drizzle-kit (migrations, utils).
*
* NOTE: IGNORE WARNINGS
*
* - IGNORED Warning: '@neondatabase/serverless' can only connect to remote
* Neon/Vercel Postgres/Supabase instances through a websocket.
* - See https://github.com/drizzle-team/drizzle-orm/discussions/4723
* - One fix is to add package `pg` as a dev dependency.
* - Conclusion: Avoid doing that, if possible. Just ignore the warning.
*/
import { readFileSync, readdirSync, existsSync } from "node:fs";
import { dirname, join } from "node:path";
// import { fileURLToPath } from "node:url";
import dotenv from "dotenv";
import { defineConfig } from "drizzle-kit";

// const __filename = fileURLToPath(import.meta.url);
// const __dirname = dirname(__filename);

const devEnv = readFileSync(join(__dirname, "../../workers/server/.dev.vars"));
const env = dotenv.parse<{ MAIN_DB_URL?: string }>(devEnv);

export default defineConfig({
breakpoints: false,
verbose: true,
dbCredentials: {
url: env.MAIN_DB_URL!,
},
dialect: "postgresql",
migrations: {
prefix: "index",
schema: "public",
// table: "__drizzle_migrations", // Default: "__drizzle_migrations"
},
// These are relative to the current working directory, in ./workers/shared/
out: "../../db/main/migrations",
schema: "src/db/main/schema.ts",
schemaFilter: ["public"],
});
/**
* @file Configuration for drizzle-kit (migrations, utils).
*
* NOTE: IGNORE WARNINGS
*
* - IGNORED Warning: '@neondatabase/serverless' can only connect to remote
* Neon/Vercel Postgres/Supabase instances through a websocket.
* - See https://github.com/drizzle-team/drizzle-orm/discussions/4723
* - One fix is to add package `pg` as a dev dependency.
* - Conclusion: Avoid doing that, if possible. Just ignore the warning.
*/
import { readFileSync, readdirSync, existsSync } from "node:fs";
import { dirname, join } from "node:path";
// import { fileURLToPath } from "node:url";
import dotenv from "dotenv";
import { defineConfig } from "drizzle-kit";

// const __filename = fileURLToPath(import.meta.url);
// const __dirname = dirname(__filename);

const devEnv = readFileSync(join(__dirname, "../../workers/server/.dev.vars"));
const env = dotenv.parse<{ MAIN_DB_URL?: string }>(devEnv);

export default defineConfig({
breakpoints: false,
verbose: true,
dbCredentials: {
url: env.MAIN_DB_URL!,
},
dialect: "postgresql",
migrations: {
prefix: "index",
schema: "public",
// table: "__drizzle_migrations", // Default: "__drizzle_migrations"
},
// These are relative to the current working directory, in ./workers/shared/
out: "../../db/main/migrations",
schema: "src/db/main/schema.ts",
schemaFilter: ["public"],
});
Azman
AzmanOP3d ago
Thanks @Techpure and @JustWayne, I'll give these a crack!

Did you find this page helpful?