Database Setup

Configure Supabase or MongoDB for your application

MoveFast supports two database options: Supabase (PostgreSQL) and MongoDB. The database you use depends on the branch you cloned.


Supabase

Supabase provides a managed PostgreSQL database with built-in auth, storage, and real-time features.

1. Create a Project

  1. Sign up at supabase.com
  2. Click New Project
  3. Choose your organization and set a database password
  4. Wait for the project to be provisioned

2. Get Connection Strings

  1. In your project dashboard, click Connect button in the header
  2. Click ORMs
  3. Select Prisma from the dropdown
  4. Copy the DATABASE_URL and DIRECT_URL values

3. Add Environment Variables

env
DATABASE_URL="postgresql://postgres.[project-ref]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres?pgbouncer=true"
DIRECT_URL="postgresql://postgres.[project-ref]:[password]@aws-0-[region].pooler.supabase.com:5432/postgres"
VariableDescription
DATABASE_URLPooled connection for queries (port 6543)
DIRECT_URLDirect connection for migrations (port 5432)

4. Push Schema to Database

Run Prisma to create tables in your Supabase database:

bash
npx prisma db push --schema=./prisma/supabase/schema.prisma
npx prisma generate --schema=./prisma/supabase/schema.prisma

MongoDB

MongoDB is a flexible NoSQL database. Great for rapid development and schema flexibility.

1. Create a Cluster

  1. Sign up at mongodb.com/cloud/atlas
  2. Create a new cluster (free tier available)
  3. Set up a database user with password
  4. Add your IP address to the access list (or allow all with 0.0.0.0/0)

2. Get Connection String

  1. Click Connect on your cluster
  2. Choose Connect your application
  3. Copy the connection string

3. Add Environment Variables

env
MONGODB_URI="mongodb+srv://username:password@cluster.mongodb.net/dbname"
VariableDescription
MONGODB_URIYour MongoDB Atlas connection string

Note: Replace username, password, and dbname with your actual values.