pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

[Bug] "Role does not exist"

Open GTonehour opened this issue 11 months ago • 2 comments

--script.sql
CREATE SCHEMA app;
ALTER SCHEMA app OWNER To user1;

pgschema plan --user user1 --db db --password ... --file script.sql fails with Error: failed to apply desired state: failed to apply schema SQL to temporary schema pgschema_tmp_20260103_180559_4d8f8276: ERROR: role "user1" does not exist (SQLSTATE 42704).

I suppose I didn't understand the context (schema, role) in which pgschema executes?

GTonehour avatar Jan 03 '26 17:01 GTonehour

pgschema operates inside a schema, which means database level commands such as "CREATE SCHEMA xxx" is not supported https://www.pgschema.com/syntax/unsupported#database-level-commands.

tianzhou avatar Jan 04 '26 02:01 tianzhou

Sure, thanks. I was using the result of pg_dump (all schemas), I'll use pgschema dump --schema app instead.

GTonehour avatar Jan 04 '26 07:01 GTonehour