sqldef icon indicating copy to clipboard operation
sqldef copied to clipboard

[WIP][psqldef] postgresql table constraints exclusion

Open sanemat opened this issue 1 year ago • 2 comments

Not completed yet

Postgresql has exclude constraint.

CREATE TABLE exclude_example (
  name varchar(255),
  event_start tstzrange NOT NULL,
  event_end tstzrange NOT NULL,
  EXCLUDE (name WITH =),
  EXCLUDE (lower(name) WITH =) where (name <> ''),
  EXCLUDE USING GIST (event_start WITH &&, event_end WITH &&)
);

This is a table constraint:

EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [ WHERE ( predicate ) ]

https://www.postgresql.org/docs/15/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION https://www.postgresql.org/docs/15/sql-createtable.html#SQL-CREATETABLE-EXCLUDE

fixes #473

sanemat avatar May 26 '24 12:05 sanemat

remaining is generator?

sanemat avatar May 26 '24 12:05 sanemat

I skipped index_parameters, because it's optional and in psqldef, we don't handle it yet.

index_parameters in UNIQUE, PRIMARY KEY, and EXCLUDE constraints are:

[ INCLUDE ( column_name [, ... ] ) ]
[ WITH ( storage_parameter [= value] [, ... ] ) ]
[ USING INDEX TABLESPACE tablespace_name ]

sanemat avatar May 26 '24 12:05 sanemat