From d23333230044909aeb10c5a5a86b454ffaa7de6e Mon Sep 17 00:00:00 2001 From: Stan Wohlwend Date: Wed, 6 Mar 2024 16:13:08 +0100 Subject: [PATCH 1/2] `psql` npm command --- package.json | 1 + packages/stack-server/package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index 5c1b0de7d..6287523be 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build:server": "turbo run build --no-cache --filter=@stackframe/stack-server...", "clean": "turbo run clean --no-cache && rimraf node_modules", "codegen": "turbo run codegen --no-cache", + "psql:server": "pnpm run --filter=@stackframe/stack-server psql", "prisma:server": "pnpm run --filter=@stackframe/stack-server prisma", "dev": "turbo run dev --parallel --continue", "dev:app": "turbo run dev --continue --filter=@stackframe/dev-app...", diff --git a/packages/stack-server/package.json b/packages/stack-server/package.json index 7471a90c4..f2f2d9d0a 100644 --- a/packages/stack-server/package.json +++ b/packages/stack-server/package.json @@ -14,6 +14,7 @@ "analyze-bundle": "npm run todo; ANALYZE_BUNDLE=1 npm run build", "start": "npm run todo; next start", "codegen": "npm run todo; npm run prisma -- generate", + "psql": "npm run todo; npm run with-env -- bash -c 'psql $DATABASE_CONNECTION_STRING'", "prisma": "npm run todo; npm run with-env -- prisma", "email": "email dev --port 3001 --dir src/email/templates", "lint": "npm run todo; next lint", From 6ea4d0b4e49e094e372aea8786eaef3538d45d7d Mon Sep 17 00:00:00 2001 From: Stan Wohlwend Date: Wed, 6 Mar 2024 16:17:45 +0100 Subject: [PATCH 2/2] Update README --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71de9ee6f..42fe017f4 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,12 @@ npm install @stackframe/stack For setup, refer to [our documentation](https://docs.stackframe.co). -## Development Setup +## Development This is for you if you want to contribute to the Stack project. +### Setup + Make sure you have `pnpm` installed alongside Node v20. Next, ensure you created `.env.local` files by copying `.env` in each of the subpackages in the `packages` folder and filling out the variables. You will need to start a Postgres database; you can do this with the following command: ```sh @@ -53,7 +55,9 @@ pnpm install pnpm run codegen # After starting a Postgres database and filling the corresponding variables in .env.local, push the schema to the database: -pnpm run prisma:server -- db reset +# for production databases, use `deploy` instead. See: https://www.prisma.io/docs/orm/prisma-migrate/understanding-prisma-migrate/mental-model#prisma-migrate-in-a-staging-and-production-environment +pnpm run prisma:server -- migrate reset + # Start the dev server pnpm run dev @@ -64,3 +68,11 @@ You can also open Prisma Studio to see the database interface and edit data dire ```sh pnpm run prisma:server -- studio ``` + +### Database migrations + +If you make changes to the Prisma schema, you need to run the following command to create a migration: + +```sh +pnpm run prisma:server -- migrate dev +```