- Accessible PostgreSQL server with a database. You can create one using Docker:
docker run \
--name postgres-17 \
-e POSTGRES_PASSWORD=password \
-p 5432:5432 \
-v ~/.postgres:/var/lib/postgresql/data \
-d \
postgres:17
- Install dependencies
npm install
- Generate Auth.js secret (and create your
.env
file)
# This will generate the .env file for you
echo "AUTH_SECRET=\"$(npx auth secret --raw)\"" >> .env
- Set the
DATABASE_URL
env var in.env
DATABASE_URL="postgresql://postgres:password@localhost:5432/hope_for_haiti"
- (OPTIONAL) Set the
SENDGRID_API_KEY
andSENDGRID_SENDER
env vars in.env
SENDGRID_API_KEY="abcdefg"
SENDGRID_SENDER="[email protected]"
- Initialize the database
npm run db:migrate
npm run db:seed
This project uses Prisma as its ORM, but wraps some of its commands for ease of access.
Viewing the Database
npm run db:view
Making Schema Changes
- Change the schema
- Generate the migration
# This will prompt you to name the migration. Usually something like "add xyz table"
npm run db:migrate
Seeding the Database
npm run db:seed