What
when using TYPE columns, especially ones that NEED quotes, like
CREATE TYPE "user" AS ....
- schema dumps are not generated with quoted column names
- even if you add quotes manually to the schema, the planned sql has the quotes stripped out.
this prevents application as the user column can't be applied, as it's interpreted as a reserved keyword.
Repro
Schema
--
-- pgschema database dump
--
-- Dumped from database version PostgreSQL 15.6
-- Dumped by pgschema version 1.9.0
--
-- Name: user; Type: TYPE; Schema: -; Owner: -
--
CREATE TYPE "user" AS (id uuid);
--
-- Name: mytable; Type: TABLE; Schema: -; Owner: -
--
CREATE TABLE IF NOT EXISTS mytable (
id uuid DEFAULT gen_random_uuid(),
entered_by "user"
);
Apply
PGPASSWORD=postgres pgschema apply --host localhost --port 5432 --db ${DB} --user ${USER} --schema my_schema --file schema.my_schema..sql --auto-approve --debug
Log
time=2026-04-24T11:36:13.268-07:00 level=DEBUG msg="Attempting database connection" host=localhost port=5431 database=omskitdb user=valstro sslmode=prefer application_name=""
time=2026-04-24T11:36:13.288-07:00 level=DEBUG msg="Database connection established successfully"
time=2026-04-24T11:36:17.237-07:00 level=DEBUG msg="Attempting database connection" host=localhost port=38779 database=pgschema_temp user=valstro sslmode=disable application_name=""
time=2026-04-24T11:36:17.245-07:00 level=DEBUG msg="Database connection established successfully"
time=2026-04-24T11:36:17.245-07:00 level=DEBUG msg="Attempting database connection" host=localhost port=5431 database=omskitdb user=valstro sslmode=prefer application_name=pgschema
time=2026-04-24T11:36:17.258-07:00 level=DEBUG msg="Database connection established successfully"
time=2026-04-24T11:36:17.393-07:00 level=DEBUG msg="Executing SQL" description="drop temporary schema" sql="DROP SCHEMA IF EXISTS \"pgschema_tmp_20260424_113613_3862bd0f\" CASCADE"
time=2026-04-24T11:36:17.393-07:00 level=DEBUG msg="SQL execution succeeded" description="drop temporary schema"
time=2026-04-24T11:36:17.393-07:00 level=DEBUG msg="Executing SQL" description="create temporary schema" sql="CREATE SCHEMA \"pgschema_tmp_20260424_113613_3862bd0f\""
time=2026-04-24T11:36:17.402-07:00 level=DEBUG msg="SQL execution succeeded" description="create temporary schema"
time=2026-04-24T11:36:17.402-07:00 level=DEBUG msg="Executing SQL" description="set search_path for desired state" sql="SET search_path TO \"pgschema_tmp_20260424_113613_3862bd0f\", public"
time=2026-04-24T11:36:17.402-07:00 level=DEBUG msg="SQL execution succeeded" description="set search_path for desired state"
time=2026-04-24T11:36:17.403-07:00 level=DEBUG msg="Executing SQL" description="apply desired state SQL to temporary schema" sql="--\n-- pgschema database dump\n--\n\n-- Dumped from database version PostgreSQL 15.6\n-- Dumped by pgschema version 1.9.0\n\n--\n-- Name: user; Type: TYPE; Schema: -; Owner: -\n--\n\nCREATE TYPE \"user\" AS (id uuid);\n\n--\n-- Name: mytable; Type: TABLE; Schema: -; Owner: -\n--\n\nCREATE TABLE IF NOT EXISTS mytable (\n id uuid DEFAULT gen_random_uuid(),\n entered_by \"user\"\n);\n\n"
time=2026-04-24T11:36:17.415-07:00 level=DEBUG msg="SQL execution succeeded" description="apply desired state SQL to temporary schema"
time=2026-04-24T11:36:17.416-07:00 level=DEBUG msg="Attempting database connection" host=localhost port=38779 database=pgschema_temp user=valstro sslmode=disable application_name=pgschema
time=2026-04-24T11:36:17.424-07:00 level=DEBUG msg="Database connection established successfully"
time=2026-04-24T11:36:17.485-07:00 level=DEBUG msg="Attempting database connection" host=localhost port=5431 database=omskitdb user=valstro sslmode=prefer application_name=pgschema
time=2026-04-24T11:36:17.496-07:00 level=DEBUG msg="Database connection established successfully"
Plan: 2 to add.
Summary by type:
types: 1 to add
tables: 1 to add
Types:
+ user
Tables:
+ mytable
DDL to be executed:
--------------------------------------------------
CREATE TYPE "user" AS (id uuid);
CREATE TABLE IF NOT EXISTS mytable (
id uuid DEFAULT gen_random_uuid(),
entered_by user
);
Applying changes...
time=2026-04-24T11:36:17.615-07:00 level=DEBUG msg="Attempting database connection" host=localhost port=5431 database=omskitdb user=valstro sslmode=prefer application_name=pgschema
time=2026-04-24T11:36:17.626-07:00 level=DEBUG msg="Database connection established successfully"
time=2026-04-24T11:36:17.626-07:00 level=DEBUG msg="Executing SQL" description="set search_path to target schema" sql="SET search_path TO orders_snapshots, public"
time=2026-04-24T11:36:17.627-07:00 level=DEBUG msg="SQL execution succeeded" description="set search_path to target schema"
Set search_path to: orders_snapshots, public
Executing group 1/1...
Executing 2 statements in implicit transaction
time=2026-04-24T11:36:17.627-07:00 level=DEBUG msg="Executing SQL" description="execute 2 statements in group 1" sql="CREATE TYPE \"user\" AS (id uuid);;\nCREATE TABLE IF NOT EXISTS mytable (\n id uuid DEFAULT gen_random_uuid(),\n entered_by user\n);;"
time=2026-04-24T11:36:17.627-07:00 level=DEBUG msg="SQL execution failed" description="execute 2 statements in group 1" error="ERROR: syntax error at or near \"user\" (SQLSTATE 42601)"
Error: failed to execute concatenated statements in group 1: ERROR: syntax error at or near "user" (SQLSTATE 42601)
What
when using
TYPEcolumns, especially ones that NEED quotes, likethis prevents application as the
usercolumn can't be applied, as it's interpreted as a reserved keyword.Repro
Schema
Apply
Log