chore: update doc to make DATABASE_URL required

This commit is contained in:
Tianzhou Chen
2023-05-06 01:44:55 +08:00
parent 5bb8a232e2
commit 8e3d220d0d
3 changed files with 31 additions and 28 deletions

View File

@ -1,2 +1,3 @@
# see process.d.ts # see process.d.ts
DATABASE_URL=postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat
OPENAI_API_KEY=YOUR_OPENAI_API_KEY OPENAI_API_KEY=YOUR_OPENAI_API_KEY

View File

@ -61,45 +61,46 @@ docker run --name sqlchat --platform linux/amd64 --env OPENAI_API_KEY=xxx --env
## Local Development ## Local Development
1. Make a copy of the example environment variables file; 1. Make a copy of the example environment variables file:
```bash ```bash
cp .env.example .env cp .env.example .env
``` ```
2. Add your [API key](https://platform.openai.com/account/api-keys) and OpenAI API Endpoint(optional) to the newly created `.env` file; 1. Add your [API key](https://platform.openai.com/account/api-keys) and OpenAI API Endpoint(optional) to the newly created `.env` file.
3. Install dependencies and start the dev server; 1. Start a Postgres instance. For mac, you can use [StackbBricks](https://stackbricks.app/), [DBngin](https://dbngin.com/) or [Postgres.app](https://postgresapp.com/). Create a database:
```bash ```sql
pnpm i && pnpm dev CREATE DATABASE sqlchat;
``` ```
In `.env` file, assign the connection string to `DATABASE_URL`.
### Database Setup
1. Install dependencies 1. Install dependencies
```bash ```bash
pnpm i pnpm i
``` ```
1. Generate prisma client from the model 1. Generate schema
```bash 1. Generate prisma client from the model
pnpm prisma generate
```
1. Migrate schema ```bash
pnpm prisma generate
```
```bash 1. Migrate schema
pnpm prisma migrate dev
```
1. Seed data ```bash
pnpm prisma migrate dev
```
```bash 1. (Optional) Seed data
pnpm prisma db seed
``` ```bash
pnpm prisma db seed
```
## Star History ## Star History

5
process.d.ts vendored
View File

@ -2,12 +2,13 @@ declare namespace NodeJS {
export interface ProcessEnv { export interface ProcessEnv {
// Required. Node environment. // Required. Node environment.
NODE_ENV: string; NODE_ENV: string;
// Required. Postgres database connection string to store the data.
// e.g. postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat
DATABASE_URL: string;
// Required. Do not share your OpenAI API key with anyone! It should remain a secret. // Required. Do not share your OpenAI API key with anyone! It should remain a secret.
OPENAI_API_KEY: string; OPENAI_API_KEY: string;
// Optional. OpenAI API endpoint. Defaults to https://api.openai.com. // Optional. OpenAI API endpoint. Defaults to https://api.openai.com.
OPENAI_API_ENDPOINT: string; OPENAI_API_ENDPOINT: string;
// Optional. Database connection string to store the data.
DATABASE_URL: string;
// Optional. API key to protect the backend API endpoint. // Optional. API key to protect the backend API endpoint.
// This needs to be exposed to the frontend and must be prefixed with NEXT_PUBLIC_. // This needs to be exposed to the frontend and must be prefixed with NEXT_PUBLIC_.
NEXT_PUBLIC_API_KEY: string; NEXT_PUBLIC_API_KEY: string;