sqldef
sqldef copied to clipboard
[WIP][psqldef] postgresql table constraints exclusion
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
remaining is generator?
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 ]