forked from blefnk/relivator-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrizzle.config.ts
38 lines (32 loc) · 1.03 KB
/
drizzle.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* drizzle-orm configuration and the init file
*
* todo: this script possibly still has window
* todo: for even more new interesting things
*
* @see https://orm.drizzle.team/kit-docs/config-reference
* @see https://discord.com/channels/1043890932593987624/1043890932593987627/1153940001885794304
*/
import path from "node:path";
import * as dotenv from "dotenv";
import { type Config } from "drizzle-kit";
/**
* Load environments before importing
* db to get access from the console.
*/
dotenv.config({ path: path.resolve(process.cwd(), ".env") });
dotenv.config({ path: path.resolve(process.cwd(), ".env.local") });
const connectionString = process.env.DATABASE_URL + "?sslmode=require";
if (!connectionString) {
throw new Error(
"[❌] Connection to database is failed.\n\
[❌] Missing database connection string.\n\
[❌] Please check DATABASE_URL variable.\n",
);
}
export default {
driver: "pg",
out: "migrations",
schema: "./src/data/db/schema.ts",
dbCredentials: { connectionString },
} satisfies Config;