| 163 | |
| 164 | @dataclass |
| 165 | class IndexBlueprint(Blueprint): |
| 166 | subject_names: List[Union[str, ExpressionBlueprint]] |
| 167 | name: Optional[str] = None |
| 168 | unique: bool = False |
| 169 | type: Optional[ |
| 170 | Literal[ |
| 171 | # https://www.postgresql.org/docs/current/indexes-types.html |
| 172 | "brin", |
| 173 | "btree", |
| 174 | "gin", |
| 175 | "gist", |
| 176 | "hash", |
| 177 | "spgist", |
| 178 | ] |
| 179 | ] = None |
| 180 | pk: bool = False |
| 181 | note: Optional[NoteBlueprint] = None |
| 182 | comment: Optional[str] = None |
| 183 | |
| 184 | table = None |
| 185 | |
| 186 | def build(self) -> 'Index': |
| 187 | return Index( |
| 188 | # TableBlueprint will process subjects |
| 189 | subjects=[], |
| 190 | name=self.name, |
| 191 | unique=self.unique, |
| 192 | type=self.type, |
| 193 | pk=self.pk, |
| 194 | note=self.note.build() if self.note else None, |
| 195 | comment=self.comment |
| 196 | ) |
| 197 | |
| 198 | |
| 199 | @dataclass |
no outgoing calls