feat(01-01): install Drizzle ORM, postgres-js, and configure DB client
- drizzle-orm@0.45.2 + postgres@3.4.9 installed (postgres-js driver) - drizzle-kit@0.31.10 installed as dev dependency - nanoid@5, zod@4, react-hook-form, @hookform/resolvers installed - src/db/index.ts: Drizzle client initialized with postgres-js driver - drizzle.config.ts: configured for postgresql dialect + src/db/schema.ts - .env.example: added as public template (no secrets) - .gitignore: allow .env.example while blocking all other .env* files
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
# Database — Postgres su Coolify
|
||||||
|
DATABASE_URL=postgresql://user:password@host:5432/database
|
||||||
+2
-1
@@ -30,8 +30,9 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
.pnpm-debug.log*
|
.pnpm-debug.log*
|
||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
# env files — exclude secrets, allow public template
|
||||||
.env*
|
.env*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { defineConfig } from "drizzle-kit";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
dialect: "postgresql",
|
||||||
|
schema: "./src/db/schema.ts",
|
||||||
|
out: "./src/db/migrations",
|
||||||
|
dbCredentials: {
|
||||||
|
url: process.env.DATABASE_URL!,
|
||||||
|
},
|
||||||
|
});
|
||||||
Generated
+1712
-7
File diff suppressed because it is too large
Load Diff
+8
-1
@@ -9,15 +9,22 @@
|
|||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@hookform/resolvers": "^5.2.2",
|
||||||
|
"drizzle-orm": "^0.45.2",
|
||||||
|
"nanoid": "^5.1.11",
|
||||||
"next": "16.2.6",
|
"next": "16.2.6",
|
||||||
|
"postgres": "^3.4.9",
|
||||||
"react": "19.2.4",
|
"react": "19.2.4",
|
||||||
"react-dom": "19.2.4"
|
"react-dom": "19.2.4",
|
||||||
|
"react-hook-form": "^7.75.0",
|
||||||
|
"zod": "^4.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
|
"drizzle-kit": "^0.31.10",
|
||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "16.2.6",
|
"eslint-config-next": "16.2.6",
|
||||||
"tailwindcss": "^4",
|
"tailwindcss": "^4",
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { drizzle } from "drizzle-orm/postgres-js";
|
||||||
|
import postgres from "postgres";
|
||||||
|
|
||||||
|
if (!process.env.DATABASE_URL) {
|
||||||
|
throw new Error("DATABASE_URL env var is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
const client = postgres(process.env.DATABASE_URL);
|
||||||
|
|
||||||
|
export const db = drizzle(client);
|
||||||
Reference in New Issue
Block a user