Repository navigation
Description
Describe the bug
Resetting databases on ANY new database (primary, or feature branch databases) now fails due to role based error:
ERROR: must be owner of sequence refresh_tokens_id_seq (SQLSTATE 42501)
Other users are also having this same problem, as noted here in this previously closed issue: #128
Summary:
- This error occurs on ALL newly created databases, including feature branches.
- Resets still work fine on older pre-existing databases before this issue was introduced.
- Investigation suggests new databases are missing the
supabase_auth_adminrole, which owns refresh_tokens_id_seq. This causes reset operations to fail because the role performing the reset operation does not have appropriate permissions for the Auth schema. - Caveat: Resetting newly created feature branches with branch type to
persistentDOES allow resets directly via Supabase UI (even though it is still missing role permissions).- HOWEVER: resetting persistent feature branches via CLI still fails, which throws exactly the same error message as when resetting primary databases (which require CLI).
- Resetting persistent feature branches via Supabase UI seems to be performing the action with different context or set of permissions than Ephemeral branches or via CLI (primary or feature branch)
Key Findings
- Older, pre-existing databases & feature branches which still have the
supabase_auth_adminrole work when resetting database (both via UI & CLI). - New databases & feature branches lack the
supabase_auth_adminrole, causing all reset operations to fail. - Cannot manually grant or alter ownership for the required role.
- Issue affects ALL projects, including brand new ones with no migrations.
- Changing a feature branch to persistent allows resets ONLY via UI, even though the role still doesn't appear in permissions.
To Reproduce
Steps to reproduce the behavior:
- Create a brand new database, or feature branch
- Run the command, note the lack of
supabase_auth_admin
SELECT rolname
FROM pg_roles
WHERE pg_has_role(current_user, oid, 'member')
ORDER BY rolname ASC;
- (Optional) If there is an older database or feature branch available, run the same command and note how it DOES have
supabase_auth_admin - Try to reset the database, using CLI command
supabase db reset --db-url postgresql://postgres.[DB_URL]:[DB_PASS]@aws-0-us-east-2.pooler.supabase.com:5432/postgres, or via the Supabase UI Reset Branch button - You will encounter this error:
ERROR: must be owner of sequence refresh_tokens_id_seq (SQLSTATE 42501)
Expected behavior
Database resets through both CLI and Supabase UI work properly as intended, including feature branches (both ephemeral and persistent).
Additional context
Evidence
Role Query Results Comparison
Query used to check roles
SELECT rolname
FROM pg_roles
WHERE pg_has_role(current_user, oid, 'member')
ORDER BY rolname ASC;Pre-existing database results:
| rolname |
|---|
| pg_database_owner |
| pg_read_all_data |
| pg_monitor |
| pg_read_all_settings |
| pg_read_all_stats |
| pg_stat_scan_tables |
| pg_signal_backend |
| pgsodium_keyiduser |
| pgsodium_keyholder |
| pgsodium_keymaker |
| authenticated |
| anon |
| service_role |
| postgres |
| authenticator |
| supabase_auth_admin |
| supabase_storage_admin |
| supabase_realtime_admin |
New database results:
| rolname |
|---|
| pg_database_owner |
| pg_read_all_data |
| pg_monitor |
| pg_read_all_settings |
| pg_read_all_stats |
| pg_stat_scan_tables |
| pg_signal_backend |
| authenticated |
| anon |
| service_role |
| postgres |
| supabase_realtime_admin |
Failed Role Creation Attempts
GRANT supabase_auth_admin TO postgres;
-- ERROR: 42501: "supabase_auth_admin" role memberships are reserved, only superusers can grant them
ALTER SEQUENCE auth.refresh_tokens_id_seq OWNER TO postgres;
-- ERROR: permission deniedWorkarounds (only for feature branches)
- Use persistent branches (remember to delete after merge)
- Delete and recreate feature branches whenever reset is needed
- Only reset feature branches through Supabase UI, not CLI
Hypothesis
This appears to be a platform-level issue with how Supabase provisions roles in feature branches rather than a project-specific configuration problem. I'm not sure exactly when this started happening, but it's happening for me in all projects now. The fact that changing to persistent branch type allows resets suggests there may be additional permissions/configurations applied to persistent branches and running the reset in the Supabase UI vs the CLI.
Activity
[-]ERROR: Resetting databases failing on all new database & feature branches (ERROR 42501)[/-][+]ERROR: Resetting databases failing on all new databases & feature branches (ERROR 42501)[/+]dvorakjt commentedon May 9, 2025
I experienced this issue, as well. I was not using feature branches. As a temporary workaround, I had to delete the whole project and recreate it. It would be great to see if this can be addressed. Please let me know if I can provide any additional information to assist in getting to the bottom of this. Thank you!
nbinobied commentedon May 10, 2025
I'm having the same issue with fresh Db/account. Supabase Version:
@supabase/supabase-js": "^2.49.4I've gone through the following commands,
supabase init>supabase login>supabase link --project-ref <project ref>>supabase migration new initial, and it breaks at the last commandsupabase db reset --linked.However, I tried to run the same migration through UI CLI and it seems to be working fine.
Migration:
sadikekin commentedon May 10, 2025
I am also experiencing this issue!
sweatybridge commentedon May 10, 2025
Thanks for the detailed report. I will work on a fix for both cli and branching.
sweatybridge commentedon May 10, 2025
We have released the fix to branching.
You should also be able to reset using cli beta version.
sadikekin commentedon May 11, 2025
Thank you for your work @sweatybridge
Use beta version of Supabase CLI
Use prerelease version v2.22.15 of Supabase CLI
rrcabrera9625 commentedon Jun 26, 2025
Any progress with this? I am having the same error:
This happens when running migrations while starting the local project using
npx supabase startrrcabrera9625 commentedon Sep 3, 2025
Any progress??? Having now the same error when creating a new branch: