File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -620,6 +620,41 @@ class: {
620620comment on materialized view my_materialized_view is E' @foreignKey (key_1, key_2) references other_table (key_1, key_2)' ;
621621```
622622
623+ ##### @unique
624+
625+ _From PostGraphile 4.9.1_
626+
627+ Introduces a "fake" unique constraint, so `@unique col1,col2` is somewhat
628+ equivalent to the following, except it can also be applied to entities that
629+ cannot have unique constraints, e.g. views. It is up to you to ensure that your
630+ data is indeed unique on the given columns.
631+
632+ ```sql
633+ -- `@unique col1,col2` is roughly equivalent to:
634+ ALTER TABLE foo ADD CONSTRAINT fake_unique UNIQUE (col1, col2);
635+ ```
636+
637+ More than one `@unique` tag may be specified.
638+
639+ ```json5
640+ class: {
641+ my_view: {
642+ tags: {
643+ unique: [
644+ "id",
645+ "org_id,slug"
646+ ]
647+ // or:
648+ // unique: "id"
649+ }
650+ }
651+ }
652+ ```
653+
654+ ```sql
655+ comment on view my_view is E' @unique id\n@unique org,slug' ;
656+ ```
657+
623658##### Smart Tags on virtual constraints
624659
625660You can also add smart tags on virtual constraints, for example adding the
You can’t perform that action at this time.
0 commit comments