Project 1 - Admin Panel
Admin Panel - Database Setup
The Admin Panel uses PostgreSQL. You can use a local install, a cloud provider, or Docker.
Option 1: Local PostgreSQL (macOS with Homebrew)
Install and start
brew install postgresql@15
brew services start postgresql@15
Create database and run schema
createdb fda_db
psql -d fda_db -f supabase/schema-standalone.sql
Run migrations (in order)
psql -d fda_db -f supabase/migrations/add-chapters-duration-status.sql
psql -d fda_db -f supabase/migrations/add-chapters-pdf-urls.sql
psql -d fda_db -f supabase/migrations/add-enrollments-progress.sql
psql -d fda_db -f supabase/migrations/add-categories.sql
psql -d fda_db -f supabase/migrations/add-course-marketing-fields.sql
psql -d fda_db -f supabase/migrations/add-blogs.sql
psql -d fda_db -f supabase/migrations/add-chat-system.sql
psql -d fda_db -f supabase/migrations/add-notifications.sql
psql -d fda_db -f supabase/migrations/add-payments-invoices-accounting.sql
psql -d fda_db -f supabase/migrations/add-questions.sql
psql -d fda_db -f supabase/migrations/add-profile-image.sql
(Adjust filenames if your supabase/migrations folder differs.)
.env.local
DATABASE_URL=postgresql://$(whoami)@localhost:5432/fda_db
Or with a dedicated user:
createuser fda_user -P
psql -d fda_db -c "GRANT ALL PRIVILEGES ON DATABASE fda_db TO fda_user;"
# Then run schema/migrations as fda_user
DATABASE_URL=postgresql://fda_user:your_password@localhost:5432/fda_db
Option 2: Neon (cloud, free tier)
- Sign up at neon.tech and create a project.
- Copy the connection string from the dashboard.
- In Neon’s SQL editor, paste and run the contents of
supabase/schema-standalone.sql, then each migration file. - In
.env.local:
DATABASE_URL=postgresql://user:password@ep-xxx.region.aws.neon.tech/neondb?sslmode=require
Option 3: Supabase (database only)
- Create a project at supabase.com.
- In Project Settings → Database, copy the URI connection string.
- In SQL Editor, run
schema-standalone.sqland then each migration insupabase/migrations/. - Set
DATABASE_URLin.env.localto that URI.
Option 4: Docker
docker run --name fda-postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=fda_db \
-p 5432:5432 \
-d postgres:15
Then:
docker exec -i fda-postgres psql -U postgres -d fda_db < supabase/schema-standalone.sql
# Then run each migration similarly
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/fda_db
Verify setup
psql "$DATABASE_URL" -c "\dt"
You should see tables such as user_profiles, courses, modules, chapters, enrollments, etc.
After that, run the app with npm run dev and try registering a user to confirm the DB is used correctly.