diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c43fd06..1ee0dece 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: env: DATABASE_URL: ${{ secrets.DATABASE_URL_FOR_PRISMA_SQL_GENERATION }} + DIRECT_URL: ${{ secrets.DATABASE_URL_FOR_PRISMA_SQL_GENERATION }} NEXT_PUBLIC_API_ENDPOINT: "sample" NEXT_PUBLIC_FIREBASE_API_KEY: "sample" NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: "sample" diff --git a/Makefile b/Makefile index 08b771ca..8d379037 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ default: start LOCAL_DB := postgres://user:password@localhost:5432/database test: export DATABASE_URL=$(LOCAL_DB) +test: export DIRECT_URL=$(LOCAL_DB) test: export UNSAFE_SKIP_AUTH=1 test: export FIREBASE_PROJECT_ID=mock-proj test: export CORS_ALLOW_ORIGINS=http://localhost:3000,https://localhost:5173 @@ -13,6 +14,7 @@ test: dev-db ## server/.envをDATABASE_URL=postgres://user:password@localhost:5432/databaseにしてから行う dev-db: export DATABASE_URL=$(LOCAL_DB) +dev-db: export DIRECT_URL=$(LOCAL_DB) dev-db: export NEVER_LOAD_DOTENV=1 dev-db: docker stop postgres || true @@ -29,7 +31,7 @@ dev-db: sleep 1; \ done @echo "PostgreSQL is ready. Running seed..." - @cd server; bunx prisma generate; bunx prisma db push + @cd server; bunx prisma generate --sql; bunx prisma db push @bun run seed @echo "Seeding completed." diff --git a/server/.env.sample b/server/.env.sample index 35ee3a26..b5343ada 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -1,7 +1,8 @@ # Database # DATABASE_URL=postgres://johndoe:supersecretpassword@example.com:5432/dbname # below can be used for docker db created via `make dev-db` -DATABASE_URL=postgres://user:password@localhost:5432/database +DATABASE_URL=postgres://user:password@localhost:6543/database +DIRECT_URL=postgres://user:password@localhost:5432/database # CORS allow origins, separated by "," | no space is allowed before/after "," CORS_ALLOW_ORIGINS=http://localhost:3000,http://localhost:5173 diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index 339a379e..ee2c650f 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -8,6 +8,8 @@ generator client { datasource db { provider = "postgresql" url = env("DATABASE_URL") + // https://github.com/prisma/prisma/discussions/25106#discussioncomment-10500102 + directUrl = env("DIRECT_URL") } enum Day {