Your project is fully configured for Supabase migration. Here's what has been prepared:
- ✅ All 8 tables with proper structure
- ✅ UUIDs using pgcrypto (Supabase-compatible)
- ✅ Enums: user_role, complaint_status, complaint_action_type, community_post_type
- ✅ Triggers for automatic
updated_attimestamps - ✅ Row Level Security (RLS) policies for data privacy
- ✅ Seed data: categories (Roads, Water, Sanitation, Safety) + sample areas
- ✅ Performance indexes on all foreign keys and filter columns
- ✅ Updated
.env.examplewith Supabase variables - ✅ Updated
.envwith connection template - ✅ Modified
backend/express-api/src/config/db.jsto support both:- Supabase connection (via DATABASE_URL)
- Local database (via individual parameters)
- ✅ SSL automatically configured for Supabase
- ✅ Connection pooling enabled
- ✅
SUPABASE-MIGRATION.md- Complete step-by-step guide - ✅
SCHEMA-REFERENCE.md- Full schema documentation with ERD - ✅
setup-supabase.sh- Automated setup script - ✅ This file - Quick reference
- Open Supabase Dashboard
- Go to Settings → Database → Password
- Reset/copy your password (you'll need it immediately)
Edit backend/express-api/.env:
// Find this line:
DATABASE_URL=postgres://postgres:YOUR_PASSWORD@aws-0-us-west-1.pooler.supabase.com:6543/postgres
// Replace YOUR_PASSWORD with your actual password
DATABASE_URL=postgres://postgres:actual-password-here@aws-0-us-west-1.pooler.supabase.com:6543/postgres- Open Supabase Dashboard
- Click SQL Editor (left sidebar)
- Click New Query
- Copy entire content from
docs/supabase-schema.sql - Paste into the SQL editor
- Click Run button
Expected output:
Query executed successfully
✅ All tables, indexes, RLS policies, and seed data created!
cd backend/express-api
npm install # if not done
npm run devLook for:
[DB] Using DATABASE_URL for connection (Supabase or managed database)
[DB] Successfully connected to database
Server running on http://localhost:8081
# Test connection
curl http://localhost:8081/api/health
# Check categories (should return 4)
curl http://localhost:8081/api/reference/categories
# Check areas (should return 3)
curl http://localhost:8081/api/reference/areasProject URL: https://jzilwqjjaeqfkmtarefe.supabase.co
Publishable Key: sb_publishable_qeShdeXQDhcmRPpOIjpI7Q_Oyqr2mnc
Secret Key: your-supabase-service-role-key
🔒 Security: Never commit
.envto git. Add to.gitignoreif not already there.
CivicPulse/
├── docs/
│ ├── supabase-schema.sql ← Run this in SQL Editor
│ ├── SUPABASE-MIGRATION.md ← Full detailed guide
│ ├── SCHEMA-REFERENCE.md ← Schema documentation
│ └── plan/
│ └── phase-01-database/
│ ├── 01-schema.sql ← Old (reference only)
│ └── 02-seed.sql ← Old (reference only)
│
├── backend/express-api/
│ ├── .env ← Update DATABASE_URL here
│ ├── .env.example ← Template
│ └── src/config/
│ └── db.js ← Supabase-ready
│
└── scripts/
└── setup-supabase.sh ← Automated setup
# Most important - UPDATE THIS
DATABASE_URL=postgres://postgres:YOUR_PASSWORD@...
# Already set
SUPABASE_URL=https://jzilwqjjaeqfkmtarefe.supabase.co
SUPABASE_ANON_KEY=sb_publishable_...
SUPABASE_SERVICE_ROLE_KEY=sb_secret_...
JWT_SECRET=civicpulse-dev-secret-...
ADMIN_SECRET=change-me-in-production
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000// Automatically chooses based on environment:
// 1. If DATABASE_URL exists → Use Supabase connection pooler
// 2. Otherwise → Use local PostgreSQL parameters
// Already configured, no changes needed!- users - User accounts (name, email, password, role)
- areas - City zones (for geographic queries)
- complaint_categories - Reference data (Roads, Water, Sanitation, Safety)
- complaints - Anonymous complaints (no user_id, uses anonymous_user_hash)
- complaint_actions - Admin audit trail
- community_posts - User posts + resolved complaints feed
- comments - Comments on posts
- post_likes - Like tracking
- 🔒 Users only see their own account
- 🔒 Anonymous complaints are recorded anonymously
- 🔒 Admins only can update/modify complaints
- 🔒 Users can only edit their own posts/likes/comments
- 📖 Public read access to: areas, categories, complaints, posts, comments
- Backend connects successfully (
[DB] Successfully connected) -
/api/healthresponds with 200 -
/api/reference/categoriesreturns 4 categories -
/api/reference/areasreturns 3 areas - Can create complaint via API
- Can view complaints via API
- Admin actions work via API
| Issue | Solution |
|---|---|
ENOTFOUND when connecting |
Check DATABASE_URL spelling |
FATAL: password invalid |
Verify password is correct in DATABASE_URL |
Too many connections |
Using direct connection? Switch to pooler (port 6543) |
RLS policy violation |
Server-side operations need SERVICE_ROLE_KEY |
| Schema not created | Check SQL ran without errors in Supabase Dashboard |
| File | Purpose |
|---|---|
SUPABASE-MIGRATION.md |
READ THIS FIRST - Complete step-by-step guide |
SCHEMA-REFERENCE.md |
Database schema with ERD and all table definitions |
supabase-schema.sql |
Actual SQL to run in Supabase Dashboard |
setup-supabase.sh |
Automated environment setup script |
- You set up DATABASE_URL in
.env✏️ - You run the SQL migration in Supabase Dashboard 🗄️
- Backend auto-connects to Supabase 🚀
- Your frontend is ready to work with the database 🎯
- See:
docs/SCHEMA-REFERENCE.md
- See:
docs/SUPABASE-MIGRATION.md - Visit: https://supabase.com/docs
- Check:
backend/express-api/.env - See:
backend/express-api/src/config/db.js
Your CivicPulse project is now Supabase-ready. Follow the 5 setup steps above and you'll be up and running in minutes.
Status: 🟢 Configuration Complete | Ready for Migration
Last Updated: March 22, 2026
Project: CivicPulse
Database: Supabase PostgreSQL
Version: 1.0