Establish PostgreSQL DB for DataForge
Setting Up a Supabase Project and Migrating a Provided SQL Dump
Section titled “Setting Up a Supabase Project and Migrating a Provided SQL Dump”This guide will help you create a new Supabase Postgres project, set up psql
on your machine, and migrate a provided SQL dump into your database.
Prerequisites
Section titled “Prerequisites”- Supabase account: Sign up here.
- Basic terminal knowledge (Command Prompt, PowerShell, or macOS/Linux terminal).
- Provided SQL dump: You should have a file named
supabase_dump.sql
ready for migration.
Step 1: Install psql
(PostgreSQL CLI)
Section titled “Step 1: Install psql (PostgreSQL CLI)”psql
is required to interact with your Postgres database.
brew install postgresql
Linux (Debian/Ubuntu)
Section titled “Linux (Debian/Ubuntu)”sudo apt updatesudo apt install postgresql-client
Windows
Section titled “Windows”- Download PostgreSQL from here.
- During installation, make sure to include Command Line Tools.
- After installation, open Command Prompt or PowerShell and verify:
psql --version
Step 2: Create a New Supabase Project
Section titled “Step 2: Create a New Supabase Project”- Log in to the Supabase dashboard.
- Click New Project.
- Fill in the required details:
- Project Name
- Organization
- Database Password (remember this, you’ll need it later)
- Region
- Click Create new project.
- Wait a few minutes until the project is initialized.
Step 3: Get Your Supabase Database Connection String
Section titled “Step 3: Get Your Supabase Database Connection String”- Go to your project dashboard → Settings → Database → Connection Info
- Copy the connection string. It looks like this:
postgres://USER:PASSWORD@HOST:PORT/DATABASE
Ensure it includes
sslmode=require
. If not, append it manually:
?sslmode=require
Step 4: Place the SQL Dump File
Section titled “Step 4: Place the SQL Dump File”Save the provided SQL dump (supabase_dump.sql
) in a folder you can easily access, e.g., ~/Downloads
or C:\Users\YourName\Downloads
.
Step 5: Migrate the SQL Dump to Your Supabase Database
Section titled “Step 5: Migrate the SQL Dump to Your Supabase Database”Open your terminal and run:
psql "postgres://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=require" -f /path/to/supabase_dump.sql
Example
Section titled “Example”macOS/Linux:
psql "postgres://postgres:mysecretpassword@db.supabase.co:5432/postgres?sslmode=require" -f ~/Downloads/supabase_dump.sql
Windows:
psql "postgres://postgres:mysecretpassword@db.supabase.co:5432/postgres?sslmode=require" -f "C:\Users\YourName\Downloads\supabase_dump.sql"
- Replace
USER
,PASSWORD
,HOST
,PORT
,DATABASE
with your Supabase connection info. - Replace the path with where your SQL dump is saved.
Step 6: Verify the Migration
Section titled “Step 6: Verify the Migration”- Go to Supabase Dashboard → Table Editor
- Check that all tables and data from the SQL dump are present.
Troubleshooting
Section titled “Troubleshooting”- SSL issues: Ensure
?sslmode=require
is appended to the connection string. - Existing tables: If the restore fails due to existing tables, drop them first or request a dump created with the
--clean
flag.
Congratulations! Your new Supabase Postgres project is now set up and populated with the provided SQL dump.