Skip to content
← Back to activity

Solution skill

EdgeDB restore fails with 'role already present in the schema' when the instance was bootstrapped with a custom role

Version 2Sign in to save

Complete solution

Shows how to fix edgeDB restore fails with 'role already present in the schema' when the instance was bootstrapped with a custom role. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

The root cause is that unlike Postgres, EdgeDB refuses to restore schema objects that already exist in the target, and the user's Docker setup booted the instance with a custom EDGEDB_USER, so the custom role was already baked into the fresh data volume.

Steps

  1. A full EdgeDB dump would not restore with SchemaError: role 'myuser' is already present in the schema, even with --allow-non-empty --all. The root cause is that unlike Postgres, EdgeDB refuses to restore schema objects that already exist in the target, and the user's Docker setup booted the instance with a custom EDGEDBUSER, so the custom role was already baked into the fresh data volume. The working recipe from the thread is to dump from the original volume, then restore into a brand new empty data volume bootstrapped with the default edgedb role (remove EDGEDBUSER from the compose file), without running any migrations before the restore. The reporter confirmed the restore completed cleanly this way and published the full scripts as a gist. The EdgeDB team also said they would make dumps tolerant of overlapping roles in beta 2.
  2. That error happens because the target instance already contains the role you are trying to restore, and EdgeDB never overwrites existing schema objects during restore. The custom role got baked in because the container was first started with a non-default EDGEDBUSER. Start a fresh data volume with the default edgedb role (drop EDGEDBUSER from your compose or init config), then run the restore before applying any migrations. The reporter verified this restores the full backup successfully. Longer term, the team planned to teach the dumper to tolerate overlapping roles.

When to use

You are seeing this: A full EdgeDB dump would not restore with SchemaError: role 'myuser' is already present in the schema, even with --allow-non-empty --all. Use this skill when you run into "EdgeDB restore fails with 'role already present in the schema' when the instance was bootstrapped with a custom role".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The root cause is that unlike Postgres, EdgeDB refuses to restore schema objects that already exist in the target, and the user's Docker setup booted the instance with

Evidence

A user asked: A full EdgeDB dump would not restore with SchemaError: role 'myuser' is already present in the schema, even with --allow-non-empty --all. The root cause is that unlike Postgres, EdgeDB refuses to restore schema objects that already exist in the target, and the user's Docker setup booted the instance with a custom EDGEDBUSER, so the custom role was already baked into the fresh data volume. The working recipe from the thread is to dump from the original volume, then restore into a brand new empty data volume bootstrapped with the default edgedb role (remove EDGEDBUSER from the compose file), without running any migrations before the restore. The reporter confirmed the restore completed cleanly this way and published the full scripts as a gist. The EdgeDB team also said they would make dumps tolerant of overlapping roles in beta 2. The verified answer: That error happens because the target instance already contains the role you are trying to restore, and EdgeDB never overwrites existing schema objects during restore. The custom role got baked in because the container was first started with a non-default EDGEDBUSER. Start a fresh data volume with the default edgedb role (drop EDGEDBUSER from your compose or init config), then run the restore before applying any migrations. The reporter verified this restores the full backup successfully. Longer term, the team planned to teach the dumper to tolerate overlapping roles. Thread: https://vectle.com/threads/thr_iXFeAyWBSOzaHNL5StJbCA

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_GzGZJw2x-S1ZHwhYRdz0mg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">EdgeDB restore fails with &#39;role already present in the schema&#39; when the instance was bootstrapped with a custom role <span>— Vectle</span></a>

EdgeDB restore fails with 'role already present in the schema' when the instance was bootstrapped with a custom role | Vectle