Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public"
SUPABASE_URL="http://localhost:54321"
SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXXXXXXXX"
134 changes: 0 additions & 134 deletions DATABASE_SETUP.md

This file was deleted.

55 changes: 55 additions & 0 deletions docs/MIGRATE_TO_SUPABASE_MANAGED_PG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Migrating to Supabase-managed Postgres

Migrating to Supabase-managed Postgres is not necessary, but it can simplify your development workflow.

## A: Fresh start (recommended)

Use this if your local data is expendable. This will still seed from `database.json` at the project root.

```bash
npx supabase start
```

Set `DATABASE_URL` in `.env`:

```env
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public"
```

```bash
npx prisma migrate dev
```

Stop your old Postgres instance.

## B: Migrate existing data

```bash
npx supabase start
```

Set `DATABASE_URL` in `.env`:

```env
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public"
```

Dump data from your current DB:

```bash
pg_dump -h localhost -p 5432 -U sga_puck_app -d sga_db --schema=public --data-only > dump.sql
```

Restore data to Supabase-managed Postgres, setting `session_replication_role` to `replica` to avoid triggering any constraints or triggers during the restore:
```bash
psql -h 127.0.0.1 -p 54322 -U postgres -d postgres <<'EOF'
SET session_replication_role = 'replica';
\i dump.sql
EOF
```

Verify data and stop old Postgres:

```bash
npx prisma studio
```
89 changes: 89 additions & 0 deletions docs/SUPABASE_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Supabase Setup

We use a local Postgres instance **or** Supabase as the local database (managed via Prisma) and Supabase for storage (media uploads). In production, we deploy to Supabase Postgres.

## Prerequisites

- Docker running locally
- Docker desktop is easiest to setup and run: https://www.docker.com/products/docker-desktop/
- Features a nice GUI, works on all platforms
- For WSL users: install on Windows and enable WSL integration in Docker desktop settings
- Alternatively, you can install any Docker engine: https://docs.docker.com/engine/install/

## Local Development

### 1. Start Supabase

```bash
npx supabase start
```

If Docker is running, Supabase will begin creating a local instance of the necessary services. On success, it should output something like:

```
╭─────────────────────────────────────────────────╮
│ 🌐 APIs │
├─────────────┬───────────────────────────────────┤
│ Project URL │ http://127.0.0.1:54321 │
│ REST │ http://127.0.0.1:54321/rest/v1 │
│ GraphQL │ http://127.0.0.1:54321/graphql/v1 │
╰─────────────┴───────────────────────────────────╯

╭───────────────────────────────────────────────────────────────╮
│ ⛁ Database │
├─────┬─────────────────────────────────────────────────────────┤
│ URL │ postgresql://postgres:postgres@127.0.0.1:54322/postgres │
╰─────┴─────────────────────────────────────────────────────────╯

╭──────────────────────────────────────────────────────────────╮
│ 🔑 Authentication Keys │
├─────────────┬────────────────────────────────────────────────┤
│ Publishable │ sb_publishable_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX │
│ Secret │ sb_secret_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX │
╰─────────────┴────────────────────────────────────────────────╯
```

These credentials are also accessible again via `npx supabase status` if you need to reference them later.

### 2. Configure environment variables

In your `.env` copy the "Project URL" to `SUPABASE_URL`, and the "Secret" to `SUPABASE_SERVICE_ROLE_KEY`.

For `DATABASE_URL`, you may use a locally managed instance, or use the Database "URL". Append `?schema=public` to ensure Prisma uses the public schema.

```env
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres?schema=public"
SUPABASE_URL="http://127.0.0.1:54321"
SUPABASE_SERVICE_ROLE_KEY="sb_secret_XXXXXXXXX"
```

### 3. Run Prisma migrations

```bash
npx prisma migrate dev
```

This will apply the Prisma schema to your local database. You can also use `npx prisma studio` to view and manage your database records in a nice UI.

## Resetting the database
If you want to reset your database (e.g. to clear all data), you can run:

```bash
npx prisma migrate reset
```

## Stopping Supabase

```bash
npx supabase stop
```

## Configuration

The config lives in `supabase/config.toml`.

- DB: Enabled — used by both application and storage
- Storage: Enabled with a public `media` bucket
- Auth/API: Enabled because storage depends on them
- Everything else: Disabled

5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module.exports = {
reactStrictMode: true,
experimental: {
serverActions: {
bodySizeLimit: "10mb",
},
},
};
Loading
Loading