1services:2 3# ╭─ postgres ─────────────────────────────────────────────────────────╮4 5 postgres:6 image: postgres7 container_name: db8 restart: always9 user: postgres10 volumes:11 - ./db-data:/var/lib/postgresql/data12 environment:13 - POSTGRES_DB=hono14 - POSTGRES_PASSWORD=mysecretpassword15 - POSTGRES_USER=codesook16 ports:17 - 5432:543218 healthcheck:19 test: ['CMD', 'pg_isready', -U, <postgres user>]20 interval: 10s21 timeout: 5s22 retries: 523 24# ╰─ postgres ─────────────────────────────────────────────────────────╯25 26# ╭─ postgres admin ───────────────────────────────────────────────────╮27 28 pgadmin:29 image: dpage/pgadmin430 container_name: pgadmin31 restart: always32 ports:33 - '8888:80'34 environment:35 PGADMIN_DEFAULT_EMAIL: [email protected]36 PGADMIN_DEFAULT_PASSWORD: qLTrQEWZsNuBMsQGFnzKEVipU37 volumes:38 - ./pgadmin:/var/lib/pgadmin39 40# ╰─ postgres admin ───────────────────────────────────────────────────╯
docker compose -p hono-day1 up -d
pnpm add prisma @types/node -D
pnpm exec prisma init
แก้ user, pass, db ใน .env
.env
DATABASE_URL="postgresql://codesook:mysecretpassword@localhost:5432/hono?schema=public"
pnpm pkg set \'scripts.prisma:generate=prisma generate' \'scripts.prisma:push=prisma db push' \'scripts.prisma:pull=prisma db pull' \'scripts.prisma:migrate=prisma migrate dev' \'scripts.prisma:migrate:deploy=prisma migrate deploy' \'scripts.prisma:studio=prisma studio' \'scripts.prisma:reset=prisma migrate reset'
1"prisma:generate": "prisma generate",2"prisma:push": "prisma db push",3"prisma:pull": "prisma db pull",4"prisma:migrate": "prisma migrate dev",5"prisma:migrate:deploy": "prisma migrate deploy",6"prisma:studio": "prisma studio",7"prisma:reset": "prisma migrate reset"