Migrate from Heroku to Supabase
Supabase is one of the best free alternatives to Heroku Postgres. This guide shows how to migrate your Heroku Postgres database to Supabase. This migration requires the pg_dump and psql CLI tools, which are installed automatically as part of the complete PostgreSQL installation package.
Alternatively, use the Heroku to Supabase migration tool to migrate in just a few clicks.
Retrieve your Heroku database credentials #
- Log in to your Heroku account and select the project you want to migrate.
- Click Resources in the menu and select your Heroku Postgres database.
- Click Settings in the menu.
- Click View Credentials and save the following information:
- Host (
- Database (
- User (
- Password (
- Host (
Retrieve your Supabase Host #
- If you're new to Supabase, create a project.
- Go to the Database settings for your project in the Supabase Dashboard.
- Under Connection Info, note your Host (
Export your Heroku database to a file #
pg_dump with your Heroku credentials to export your Heroku database to a file (e.g.,
_10pg_dump --clean --if-exists --quote-all-identifiers \_10-h $HEROKU_HOST -U $HEROKU_USER -d $HEROKU_DATABASE \_10--no-owner --no-privileges > heroku_dump.sql
Import the database to your Supabase project #
psql to import the Heroku database file to your Supabase project.
_10psql -h $SUPABASE_HOST -U postgres -f heroku_dump.sql
- To only migrate a single database schema, add the
--schema=PATTERNparameter to your
- To exclude a schema:
- To only migrate a single table:
- To exclude a table:
pg_dump --help for a full list of options.
If you're planning to migrate a database larger than 6 GB, we recommend upgrading to at least a Large compute add-on. This will ensure you have the necessary resources to handle the migration efficiently.
For databases smaller than 150 GB, you can increase the size of the disk on paid projects by navigating to Database Settings.
If you're dealing with a database larger than 150 GB, we strongly advise you to contact our support team for assistance in provisioning the required resources and ensuring a smooth migration process.