Skip to content

Schema dump does not preserve INCLUDE columns on CREATE INDEX #385

@McVeyMason

Description

@McVeyMason

When adding an INDEX with an INCLUDE, the schema dump adds it as part of the indexed columns.

Repro SQL code

CREATE SCHEMA test;

CREATE TABLE test.test_table (
    id int PRIMARY KEY,
    col1 uuid NOT NULL,
    col2 int NOT NULL,
    included_col text NOT NULL
);

CREATE INDEX test_table_col1_col2 ON test.test_table (col1, col2) INCLUDE (included_col); 

Dump schema

pgschema dump --schema test

Expected output

CREATE TABLE IF NOT EXISTS test_table (
  id integer,
  col1 uuid NOT NULL,
  col2 integer NOT NULL,
  included_col text NOT NULL,
  CONSTRAINT test_table_pkey PRIMARY KEY (id)
);


CREATE INDEX IF NOT EXISTS test_table_col1_col2 ON test_table (col1, col2) INCLUDE (included_col);

Actual output

CREATE TABLE IF NOT EXISTS test_table (
  id integer,
  col1 uuid NOT NULL,
  col2 integer NOT NULL,
  included_col text NOT NULL,
  CONSTRAINT test_table_pkey PRIMARY KEY (id)
);

CREATE INDEX IF NOT EXISTS test_table_col1_col2 ON test_table (col1, col2, included_col);

Environment

  • PostgreSQL 18.1
  • pgschema v1.8.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions