pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

reserved keyword double quote inconsistency

Open tomi-rtk opened this issue 9 months ago • 0 comments

When generating a plan into a .sql (or .json) file pgschema will correctly quote reserved keywords when executing ALTER TABLE statements but not when generating indexes. I know it is very unwise to name your tables with the same reserved keyword identifier but it's a legacy database and I cannot rename tables at this moment.,

Example:

ALTER TABLE "order"
ADD COLUMN tenant_id uuid CONSTRAINT "FK_order_tenant" REFERENCES tenant (id);

CREATE INDEX CONCURRENTLY IF NOT EXISTS "IDX_order_tenant_order_number" ON order (tenant_id, order_number);

My current strategy is executing this in my github workflow file, just after the plan generation.

sed -i 's/ON order /ON "order" /g' plan.sql

tomi-rtk avatar Feb 12 '26 10:02 tomi-rtk