Home

Migrating and Upgrading Projects

Supabase ships fast and we endeavor to add all new features to existing projects wherever possible. In some cases, access to new features require upgrading or migrating your Supabase project.

Upgrade your project#

note

This is only available for projects on the Free plan. For projects on the Pro plan, please contact support for assistance with upgrading.

When you pause and restore a project, the restored database includes the latest features. This method does include downtime, so be aware that your project will be inaccessible for a short period of time.

  1. On the General Settings page in the Dashboard, click Pause project. You will be redirected to the home screen as your project is pausing. This process can take several minutes.
  2. After your project is paused, click Restore project. The restoration can take several minutes depending on how much data your database has. You will receive an email once the restoration is complete.

Migrate your project#

Migrating projects can be achieved using the Supabase CLI. This is particularly useful for older projects (e.g. to use a newer Postgres version).

Before you begin#

  • Install Postgres so you can run psql and pg_dump.
  • Install Supabase CLI.
  • Create a new Supabase project.
  • Install Docker Desktop for your platform.
  • Set environment variables for the old project's database URL as $OLD_DB_URL and the new project's as $NEW_DB_URL. To find the database URL for a project, go to the project's dashboard page Project Settings/Database and look at Connection string / URI. For example, to set the $OLD_DB_URL you would run export OLD_DB_URL=postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF#].supabase.co:5432/postgres.

Backup your old database#

  1. Run the following command from your terminal:

_10
supabase db dump --db-url "$OLD_DB_URL" -f roles.sql --role-only
_10
supabase db dump --db-url "$OLD_DB_URL" -f schema.sql
_10
supabase db dump --db-url "$OLD_DB_URL" -f data.sql --use-copy --data-only

Restore to your new project#

In your new project:

  1. Enable Database Webhooks if you enabled them in your old project.
  2. Enable any extensions that were enabled in your old project.

Then run the following command from your terminal:


_10
psql \
_10
--single-transaction \
_10
--variable ON_ERROR_STOP=1 \
_10
--file roles.sql \
_10
--file schema.sql \
_10
--file data.sql \
_10
--dbname "$NEW_DB_URL"

Notes:

  • If you have created any custom roles with login attribute, you have to manually set their passwords in the new project.
  • If you receive any permission errors when running supabase db dump --db-url "$OLD_DB_URL" -f schema.sql, you may need to edit the schema.sql file and change any lines saying OWNER TO "supabase_admin" to OWNER TO "postgres".

Enable publication on tables#

Replication for Realtime is disabled for all tables in your new project. On the Replication page in the Dashboard, select your new project and enable replication for tables that were enabled in your old project.

Migrate Storage objects#

The new project has the old project's Storage buckets, but the Storage objects need to be migrated manually. Use this script to move storage objects from one project to another.


_52
// npm install @supabase/supabase-js@1
_52
const { createClient } = require('@supabase/supabase-js')
_52
_52
const OLD_PROJECT_URL = 'https://xxx.supabase.co'
_52
const OLD_PROJECT_SERVICE_KEY = 'old-project-service-key-xxx'
_52
_52
const NEW_PROJECT_URL = 'https://yyy.supabase.co'
_52
const NEW_PROJECT_SERVICE_KEY = 'new-project-service-key-yyy'
_52
_52
;(async () => {
_52
const oldSupabaseRestClient = createClient(OLD_PROJECT_URL, OLD_PROJECT_SERVICE_KEY, {
_52
db: {
_52
schema: 'storage',
_52
},
_52
})
_52
const oldSupabaseClient = createClient(OLD_PROJECT_URL, OLD_PROJECT_SERVICE_KEY)
_52
const newSupabaseClient = createClient(NEW_PROJECT_URL, NEW_PROJECT_SERVICE_KEY)
_52
_52
// make sure you update max_rows in postgrest settings if you have a lot of objects
_52
// or paginate here
_52
const { data: oldObjects, error } = await oldSupabaseRestClient.from('objects').select()
_52
if (error) {
_52
console.log('error getting objects from old bucket')
_52
throw error
_52
}
_52
_52
for (const objectData of oldObjects) {
_52
console.log(`moving ${objectData.id}`)
_52
try {
_52
const { data, error: downloadObjectError } = await oldSupabaseClient.storage
_52
.from(objectData.bucket_id)
_52
.download(objectData.name)
_52
if (downloadObjectError) {
_52
throw downloadObjectError
_52
}
_52
_52
const { _, error: uploadObjectError } = await newSupabaseClient.storage
_52
.from(objectData.bucket_id)
_52
.upload(objectData.name, data, {
_52
upsert: true,
_52
contentType: objectData.metadata.mimetype,
_52
cacheControl: objectData.metadata.cacheControl,
_52
})
_52
if (uploadObjectError) {
_52
throw uploadObjectError
_52
}
_52
} catch (err) {
_52
console.log('error moving ', objectData)
_52
console.log(err)
_52
}
_52
}
_52
})()

Transfer to a different organization#

Note that project migration is for transferring your projects to different regions. If you need to move your project to a different organization without touching the infrastrusture, see project transfers.