You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supabase doesn't offer a dedicated maintenance or read-only mode for a project. During a migration, you can make the source database read-only at the Postgres level and reduce writes from your application.
Make the database read-only
To stop new connections from writing, set default_transaction_read_only on the source database:
alterdatabase your_database_name set default_transaction_read_only = true;
This is a database-level default, so it's a soft freeze and not a complete block on writes:
Sessions and services that already have open connections keep their previous value until they reconnect. This can include the Data API, Auth, and Storage.
A session can override the setting for itself. The Data API runs write requests in explicit read-write transactions, so API requests might still write.
After they reconnect, Auth and Storage can reject writes. Storage returns a read-only error. Auth returns a generic server error.
Because the database setting doesn't stop every write path, pausing writes in your application is the most reliable way to freeze writes. Pause writes from your application and any background jobs for the migration window. You can also put a maintenance page in front of your client apps.
Re-enable writes
What you do after the migration depends on the method you used:
Dump and restore: If you keep the source project, re-enable writes when you finish.
Logical replication: Keep the source read-only, or decommission it. Don't re-enable writes, to avoid a split-brain scenario.
To re-enable writes, run the following in a transaction that switches to read-write first. This covers the case where the database rejects the change because it's already read-only:
begin;
set transaction read write;
alterdatabase your_database_name set default_transaction_read_only = off;
commit;
After you re-enable writes, restart or reconnect your applications and services. Connections that opened while the setting was on can stay read-only until they reconnect.
While the setting is on, tools that need to run as read-write, such as the Supabase CLI's database commands, can fail. If that happens, run the SQL above in the SQL Editor in the Dashboard. If you restart your project while the setting is on, some services might not start cleanly until you turn it off.
If your database is read-only and you didn't set it
Supabase can put a project into read-only mode when disk usage passes 95%. This is separate from the steps above. For how it works and how to disable it, see Database size.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Supabase doesn't offer a dedicated maintenance or read-only mode for a project. During a migration, you can make the source database read-only at the Postgres level and reduce writes from your application.
Make the database read-only
To stop new connections from writing, set
default_transaction_read_onlyon the source database:This is a database-level default, so it's a soft freeze and not a complete block on writes:
6543) might not pick up the change straight away. Restart or reconnect your apps after you set it. For more on how pooled connections keep session state, see Resolving 'cannot execute UPDATE in a read-only transaction' on transaction pooler connections.Reduce writes from your application
Because the database setting doesn't stop every write path, pausing writes in your application is the most reliable way to freeze writes. Pause writes from your application and any background jobs for the migration window. You can also put a maintenance page in front of your client apps.
Re-enable writes
What you do after the migration depends on the method you used:
To re-enable writes, run the following in a transaction that switches to read-write first. This covers the case where the database rejects the change because it's already read-only:
After you re-enable writes, restart or reconnect your applications and services. Connections that opened while the setting was on can stay read-only until they reconnect.
While the setting is on, tools that need to run as read-write, such as the Supabase CLI's database commands, can fail. If that happens, run the SQL above in the SQL Editor in the Dashboard. If you restart your project while the setting is on, some services might not start cleanly until you turn it off.
If your database is read-only and you didn't set it
Supabase can put a project into read-only mode when disk usage passes 95%. This is separate from the steps above. For how it works and how to disable it, see Database size.
Related guides
All reactions