Heroku to Supabase Migration Guide
- A Heroku project with a Postgres database you want to migrate to Supabase
- A Supabase project you want to migrate into
- pg_dump command-line tool installed
- psql command-line tool installed
- Log into Heroku (https://heroku.com)
- Select your project
- Click
Resources
in the menu - Select your
Heroku Postgres
database - Click
Settings
in the menu - Click
View Credentials
- Save your credentials:
- Host (
$HEROKU_HOST
) - Database (
$HEROKU_DATABASE
) - User (
$HEROKU_USER
) - Password (
$HEROKU_PASSWORD
)
- Host (
- Log into the Supabase Dashboard (https://supabase.com)
- Select your project
- Select Settings / Database
- Under Connection Info / Host, note your Host (
$SUPABASE_HOST
)
pg_dump --clean --if-exists --quote-all-identifiers \
-h $HEROKU_HOST -U $HEROKU_USER -d $HEROKU_DATABASE \
--no-owner --no-privileges > heroku_dump.sql
psql -h $SUPABASE_HOST -U postgres -f heroku_dump.sql
If you're using graphql with your Supabase projects, you may need to issue the following SQL command in your Supabase Dashboard (Query Editor) to make sure the new tables show up:
select graphql.rebuild_schema();
- To only migrate a single database schema, add the
--schema=PATTERN
parameter to yourpg_dump
command. - To exclude a schema:
--exclude-schema=PATTERN
. - To only migrate a single table:
--table=PATTERN
. - To exclude a tables:
--exclude-table=PATTERN
.
Run pg_dump --help
for a full list of options.