Database

Setup of Prisma and Supabase

We use Supabase for the database. It's free and open-source and Prisma as an ORM to help with the query.

Setup

Follow the steps at Supabase Sign up

  1. Go to Supabase and create a new project and make sure to copy the generate password!, for region, choose the closest to you.

  2. Wait a few minutes for the setup to complete, then click on "connect" on the top menu.

  3. Navigate to ORMs tab, choose Prisma Supabase Prisma Connection

  4. Copy the DATABASE_URL and DIRECT_URL values to your .env file and replace "YOUR PASSWORD" accordingly:

DATABASE_URL="..."

DIRECT_URL="..."
  1. Initialize your database schema by running (already pre-configured for you):
bunx prisma migrate dev --name init && bun run prisma generate

That's it! all the basic configuration is done.

Database Schema Overview

The database schema is defined in /prisma/schema.prisma. This schema file uses Prisma’s schema definition language to describe your database tables, relationships, and types.

Add new fields

To update your database schema, you can edit the schema.prisma.

For example to add a new table for articles

-- /prisma/schema.prisma
 
model Articles {
  // ...
  title          String?
  // ...
 
}

Apply our new migration and update our client.

bunx prisma migrate dev --name add_articles && bun run prisma generate

Now your changes are available on the database!

On this page