Skip to content

Bug: Schema with quoted mixed-case custom types cannot be round-tripped #422

@vytautas-karpavicius

Description

@vytautas-karpavicius

pgschema version: 1.9.0

Description

A schema with quoted mixed-case custom type names cannot be round-tripped through pgschema dump + pgschema plan. The dump produces a desired state file that pgschema plan refuses to load.

Steps to reproduce

# 0. Start PostgreSQL
docker run --rm -d --name pg15 -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres:15

# 1. Create databases and load the schema
psql -h localhost -U postgres -c "CREATE DATABASE plandb"
psql -h localhost -U postgres -c "CREATE DATABASE targetdb"
psql -h localhost -U postgres -d targetdb -c "
CREATE TYPE \"MyStatus\" AS ENUM ('active', 'inactive');
CREATE TABLE items (
    id     bigint NOT NULL,
    status \"MyStatus\" DEFAULT 'active'::\"MyStatus\" NOT NULL,
    CONSTRAINT items_pkey PRIMARY KEY (id)
);
"

# 2. Dump the schema
pgschema dump \
  --host localhost --port 5432 --user postgres \
  --db targetdb --sslmode disable \
  > desired.sql

# 3. Plan against the same database — expects zero drift
pgschema plan \
  --host localhost --port 5432 --user postgres \
  --db targetdb --sslmode disable \
  --plan-host localhost --plan-port 5432 \
  --plan-user postgres --plan-db plandb --plan-sslmode disable \
  --file desired.sql

Expected result

No changes detected.

Actual result

Error: failed to apply desired state: failed to apply schema SQL to temporary schema
pgschema_tmp_...: ERROR: type "mystatus" does not exist (SQLSTATE 42704)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions