Repository navigation
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
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
jsonMartin commentedon May 9, 2025
Another confirmed case of this issue from @dvorakjt : #3551 (comment)
albttx commentedon May 11, 2025
I'm having the issue also...
paulteriele commentedon May 12, 2025
I'm experiencing this issue too, and not just in new projects, also in existing projects. Although it doesn't directly errors in the command line interface, it does so when trying to authenticate.
Resulting in an error in existing projects too
After successfully using
npm run resetI am not able to authenticate as a user via supabase-js.It results in an 500 error with the following error message:
null value in column "id" of relation "refresh_tokens" violates not-null constraintnbinobied commentedon May 12, 2025
I'm having the same issue and I've placed a comment with the debug at #3551 (comment)
Heet-Bhalodiya commentedon May 12, 2025
I am having the same issue in existing project...👀
saltcod commentedon May 12, 2025
Fixed here:
#3551 (comment)
You should also be able to use the cli beta version in the meantime :
npx supabase@beta db reset...Heet-Bhalodiya commentedon May 13, 2025
Hello @saltcod,
Thank you for the solution.
I would like to clarify that when using the command
npx supabase@beta db reset -db-url..., it resets the local database, even if a remote database is linked.However, using the command
npx supabase@beta db reset --linkedreset the remote database.theobugs commentedon May 14, 2025
I am also facing an issue on creating feature branches. The migrations relating to the storage schema keep failing:
ERROR: must be owner of table objects (SQLSTATE 42501) At statement 0: ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY.Checking the ownership of
storage.objectsgave mesupabase_storage_admin; so, it looks to me that some there is an issue relating to permissions of thepostgresrole, specifically for the storage schema.kacperwerema commentedon May 16, 2025
How do I install supabase beta in CI?
Right now we had a step of
uses: supabase/setup-cli@v1
with:
version: latest
Changing version to beta doesn't work
fkoulen commentedon May 19, 2025
You can set the version to one of the pre-releases, see https://github.com/supabase/cli/releases. The fix is in v2.22.15
rrcabrera9625 commentedon May 20, 2025
Setting the CLI version in the CI step like this:
did not resolve the issue. Are there any other suggestions or workarounds?
rrcabrera9625 commentedon May 20, 2025
any progress with this @kacperwerema ??
kacperwerema commentedon May 21, 2025
I've adjusted the steps a bit as there is a npm command to install the supabase@beta. (Needed to add setup for node)
Those are the steps from the pipeline.
rrcabrera9625 commentedon Jun 6, 2025
any updates on this?
baptlma commentedon Jun 18, 2025
Same issue here with
ERROR: must be owner of sequence refresh_tokens_id_seq (SQLSTATE 42501)after runningsupabase db reset --db-url [link]. Seems to be an issue on thepostgresuser permissions as @theobugs mentionnedHallidayo commentedon Jun 29, 2025
Hi, I've moved this issue over from the supabase repo.
kradkfl commentedon Jul 25, 2025
fwiw, upgrading my supabase CLI from 2.22.12 -> 2.31.8 fixed
supabase db reset --linkedfor me.github-actions commentedon Jun 17, 2026
Hi! Thanks for opening this issue.
We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.
If this still reproduces on the latest Supabase CLI, please comment with
/reopenon its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.