Skip to content

ERROR: Resetting databases failing on all new databases & feature branches (ERROR 42501) #3782

Closed as not planned

Description

@jsonMartin

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_admin role, 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 persistent DOES 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_admin role work when resetting database (both via UI & CLI).
  • New databases & feature branches lack the supabase_auth_admin role, 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:

  1. Create a brand new database, or feature branch
  2. 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;
  1. (Optional) If there is an older database or feature branch available, run the same command and note how it DOES have supabase_auth_admin
  2. 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
  3. 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 denied

Workarounds (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

  1. added
    bug
    on May 9, 2025
  2. jsonMartin commented on May 9, 2025

    @jsonMartin
    Author

    Another confirmed case of this issue from @dvorakjt : #3551 (comment)

  3. albttx commented on May 11, 2025

    @albttx

    I'm having the issue also...

  4. paulteriele commented on May 12, 2025

    @paulteriele

    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 reset I 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 constraint

    "query": "INSERT INTO \"refresh_tokens\" (\"created_at\", \"instance_id\", \"parent\", \"revoked\", \"session_id\", \"token\", \"updated_at\", \"user_id\") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) returning id",
              "
    
  5. nbinobied commented on May 12, 2025

    @nbinobied

    I'm having the same issue and I've placed a comment with the debug at #3551 (comment)

  6. Heet-Bhalodiya commented on May 12, 2025

    @Heet-Bhalodiya

    I am having the same issue in existing project...👀

  7. saltcod commented on May 12, 2025

    @saltcod
    Contributor

    Fixed here:

    #3551 (comment)

    You should also be able to use the cli beta version in the meantime :

    npx supabase@beta db reset...

  8. Heet-Bhalodiya commented on May 13, 2025

    @Heet-Bhalodiya

    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 --linked reset the remote database.

  9. theobugs commented on May 14, 2025

    @theobugs

    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.objects gave me supabase_storage_admin; so, it looks to me that some there is an issue relating to permissions of the postgres role, specifically for the storage schema.

  10. kacperwerema commented on May 16, 2025

    @kacperwerema

    How do I install supabase beta in CI?
    Right now we had a step of

    • name: Install Supabase CLI
      uses: supabase/setup-cli@v1
      with:
      version: latest

    Changing version to beta doesn't work

  11. fkoulen commented on May 19, 2025

    @fkoulen

    How do I install supabase beta in CI? Right now we had a step of

    • name: Install Supabase CLI
      uses: supabase/setup-cli@v1
      with:
      version: latest

    Changing version to beta doesn't work

    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

  12. rrcabrera9625 commented on May 20, 2025

    @rrcabrera9625

    Setting the CLI version in the CI step like this:

     - uses: supabase/setup-cli@v1
            with:
              version: 2.22.15
    

    did not resolve the issue. Are there any other suggestions or workarounds?

  13. rrcabrera9625 commented on May 20, 2025

    @rrcabrera9625

    How do I install supabase beta in CI? Right now we had a step of

    • name: Install Supabase CLI
      uses: supabase/setup-cli@v1
      with:
      version: latest

    Changing version to beta doesn't work

    any progress with this @kacperwerema ??

  14. kacperwerema commented on May 21, 2025

    @kacperwerema

    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.

    - name: Setup Node.js
            uses: actions/setup-node@v4
            with:
              node-version: "20"
    
          - name: Install Supabase CLI (beta) via NPM
            run: npm install supabase@beta --save-dev
    
  15. rrcabrera9625 commented on Jun 6, 2025

    @rrcabrera9625

    any updates on this?

  16. baptlma commented on Jun 18, 2025

    @baptlma

    Same issue here with ERROR: must be owner of sequence refresh_tokens_id_seq (SQLSTATE 42501) after running supabase db reset --db-url [link]. Seems to be an issue on the postgres user permissions as @theobugs mentionned

  17. transferred this issue fromsupabase/supabaseon Jun 29, 2025
  18. Hallidayo commented on Jun 29, 2025

    @Hallidayo
    Collaborator

    Hi, I've moved this issue over from the supabase repo.

  19. kradkfl commented on Jul 25, 2025

    @kradkfl

    fwiw, upgrading my supabase CLI from 2.22.12 -> 2.31.8 fixed supabase db reset --linked for me.

  20. github-actions commented on Jun 17, 2026

    @github-actions
    Contributor

    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 /reopen on 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.

  21. added
    stale-closed
    on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugstale-closed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions