Skip to main content

safe_migrate/analysis/
facts.rs

1use crate::analysis::expr_ir::ExprIr;
2use crate::ast::identifiers::{Ident, QualifiedName};
3
4#[derive(Clone, Debug, PartialEq)]
5pub enum PersistenceFact {
6    Permanent,
7    Temporary,
8    Unlogged,
9}
10
11#[derive(Clone, Debug, PartialEq)]
12pub enum PolicyCommand {
13    All,
14    Select,
15    Insert,
16    Update,
17    Delete,
18}
19
20#[derive(Clone, Debug, PartialEq)]
21pub enum SearchPathTarget {
22    Default,
23    Schemas(Vec<String>),
24}
25
26#[derive(Clone, Copy, Debug, PartialEq, Eq)]
27pub enum TimeoutSetting {
28    Lock,
29    Statement,
30}
31
32#[derive(Clone, Debug, PartialEq, Eq)]
33pub enum TimeoutSettingValue {
34    Default,
35    Milliseconds(u64),
36    Current,
37    Invalid(String),
38}
39
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum ResetSettingTarget {
42    All,
43    SearchPath,
44    LockTimeout,
45    StatementTimeout,
46}
47
48#[derive(Clone, Debug, PartialEq)]
49pub enum TypeCreationKind {
50    Enum { variants: Vec<String> },
51    Range,
52    Composite,
53    Base,
54}
55
56#[derive(Clone, Debug, PartialEq)]
57pub enum AlterViewAction {
58    RenameTo {
59        new_name: Ident,
60    },
61    OwnerTo {
62        new_owner: RoleFact,
63    },
64    SetSchema {
65        new_schema: String,
66    },
67    SetDefault {
68        column: String,
69        default: Option<ExprIr>,
70    },
71    DropDefault {
72        column: String,
73    },
74    RenameColumn {
75        from: Ident,
76        to: Ident,
77    },
78    SetOptions {
79        options: Vec<String>,
80    },
81    ResetOptions {
82        options: Vec<String>,
83    },
84}
85
86#[derive(Clone, Debug, PartialEq)]
87pub enum AlterSchemaActionFact {
88    RenameTo { new_name: Ident },
89    OwnerTo { new_owner: RoleFact },
90}
91
92#[derive(Clone, Debug, PartialEq)]
93pub enum StatementFact {
94    CreateSchema {
95        name: QualifiedName,
96        if_not_exists: bool,
97        authorization: Option<RoleFact>,
98    },
99    AlterSchema {
100        name: QualifiedName,
101        action: AlterSchemaActionFact,
102    },
103    DropSchema {
104        names: Vec<QualifiedName>,
105        if_exists: bool,
106        cascade: bool,
107    },
108    CreateTable {
109        name: QualifiedName,
110        if_not_exists: bool,
111        as_select: bool,
112        persistence: PersistenceFact,
113        columns: Vec<ColumnFact>,
114        foreign_keys: Vec<FkFact>,
115        table_constraints: Vec<TableConstraintFact>,
116        partition_by: Option<String>,
117        partition_of: Option<QualifiedName>,
118        partition_type: Option<String>,
119    },
120    CreateView {
121        name: QualifiedName,
122        or_replace: bool,
123        depends_on: Vec<QualifiedName>,
124    },
125    AlterView {
126        name: QualifiedName,
127        action: AlterViewAction,
128    },
129    CreateMaterializedView {
130        name: QualifiedName,
131        depends_on: Vec<QualifiedName>,
132    },
133    AlterMaterializedView {
134        name: QualifiedName,
135        new_name: Option<Ident>,
136    },
137    RefreshMaterializedView {
138        name: QualifiedName,
139        concurrently: bool,
140    },
141    CreateIndex {
142        name: QualifiedName,
143        relation: QualifiedName,
144        if_not_exists: bool,
145        concurrently: bool,
146        using_method: Option<String>,
147        has_predicate: bool,
148        unique: bool, // Added for CreateIndexFact
149    },
150    CreatePolicy {
151        name: String,
152        table: QualifiedName,
153        permissive: bool,
154        command: PolicyCommand,
155        /// False when roles or policy expressions are present but not modeled.
156        semantics_complete: bool,
157    },
158    DropPolicy {
159        name: String,
160        table: QualifiedName,
161        if_exists: bool,
162    },
163    CreateTrigger {
164        name: String,
165        table: QualifiedName,
166        function: Option<QualifiedName>,
167    },
168    DropTrigger {
169        name: String,
170        table: QualifiedName,
171        if_exists: bool,
172    },
173    AlterTrigger {
174        name: String,
175        table: QualifiedName,
176        new_name: String,
177    },
178    AlterTable {
179        name: QualifiedName,
180        actions: Vec<AlterTableActionFact>,
181    },
182    AlterIndex {
183        name: QualifiedName,
184        actions: Vec<AlterIndexActionFact>,
185    },
186    CreateType(CreateTypeFact),
187    AlterType(AlterTypeFact),
188    CreateDomain {
189        name: QualifiedName,
190        base_type: String,
191    },
192    AlterDomain {
193        name: QualifiedName,
194        action: Option<AlterDomainActionFact>,
195    },
196    DropDomain {
197        names: Vec<QualifiedName>,
198        if_exists: bool,
199        cascade: bool,
200    },
201    DropType {
202        names: Vec<QualifiedName>,
203        if_exists: bool,
204        cascade: bool,
205    },
206    CreateSequence {
207        name: QualifiedName,
208        if_not_exists: bool,
209        owned_by: Option<(QualifiedName, String)>,
210    },
211    AlterSequence {
212        name: QualifiedName,
213        if_exists: bool,
214        action: AlterSequenceActionFact,
215    },
216    DropSequence {
217        names: Vec<QualifiedName>,
218        if_exists: bool,
219        cascade: bool,
220    },
221    DropTable {
222        names: Vec<QualifiedName>,
223        if_exists: bool,
224        cascade: bool,
225    },
226    DropView {
227        names: Vec<QualifiedName>,
228        if_exists: bool,
229        cascade: bool,
230    },
231    DropMaterializedView {
232        names: Vec<QualifiedName>,
233        if_exists: bool,
234        cascade: bool,
235    },
236    DropIndex {
237        names: Vec<QualifiedName>,
238        if_exists: bool,
239        concurrently: bool,
240        cascade: bool,
241    },
242    SetSearchPath {
243        target: SearchPathTarget,
244        local: bool,
245    },
246    SetTimeout {
247        setting: TimeoutSetting,
248        value: TimeoutSettingValue,
249        local: bool,
250    },
251    ResetSettings {
252        target: ResetSettingTarget,
253    },
254    BeginTransaction,
255    CommitTransaction,
256    CommitAndChain,
257    RollbackTransaction,
258    RollbackAndChain,
259    RollbackToSavepoint {
260        name: String,
261    },
262    Savepoint {
263        name: String,
264    },
265    ReleaseSavepoint {
266        name: String,
267    },
268    PrepareTransaction {
269        name: String,
270    },
271    SetTransaction,
272    SetConstraints,
273    OpaqueBlock,
274    Execute,
275    /// Parsed SQL that changes PostgreSQL metadata but no schema state modeled
276    /// by safe-migrate, such as `COMMENT ON`.
277    SchemaNeutralNoop,
278    Vacuum {
279        relation: Option<QualifiedName>,
280        is_full: bool,
281    },
282    CreateFunction(CreateFunctionFact),
283    AlterFunction(AlterFunctionFact),
284    DropFunction(DropFunctionFact),
285    CreateProcedure(CreateProcedureFact),
286    AlterProcedure(AlterProcedureFact),
287    DropProcedure(DropProcedureFact),
288    CreateAggregate(CreateAggregateFact),
289    AlterAggregate(AlterAggregateFact),
290    DropAggregate(DropAggregateFact),
291    CreatePublication(CreatePublicationFact),
292    AlterPublication(AlterPublicationFact),
293    DropPublication(DropPublicationFact),
294    CreateSubscription(CreateSubscriptionFact),
295    AlterSubscription(AlterSubscriptionFact),
296    DropSubscription(DropSubscriptionFact),
297    CreateRole(CreateRoleFact),
298    AlterRole(AlterRoleFact),
299    DropRole(DropRoleFact),
300    Grant(GrantFact),
301    Revoke(RevokeFact),
302    CreateDatabase(CreateDatabaseFact),
303    AlterDatabase(AlterDatabaseFact),
304    DropDatabase(DropDatabaseFact),
305    /// `SET [LOCAL] ROLE { rolename | NONE }` or
306    /// `SET [LOCAL] SESSION AUTHORIZATION { rolename | DEFAULT }`.
307    /// `role = None` means NONE / DEFAULT (restore the session default).
308    /// `local = true` means the change is scoped to the current transaction.
309    /// `is_session_auth = true` means SET SESSION AUTHORIZATION (which also
310    /// updates the session-level default, unlike plain SET ROLE).
311    SetRole {
312        role: Option<RoleFact>,
313        local: bool,
314        is_session_auth: bool,
315    },
316}
317
318#[derive(Clone, Debug, PartialEq)]
319pub enum AlterSequenceActionFact {
320    OwnedBy(Option<(QualifiedName, String)>),
321    OwnerTo(RoleFact),
322    RenameTo(Ident),
323    SetSchema(String),
324    Other,
325}
326
327#[derive(Clone, Debug, PartialEq)]
328pub enum AlterIndexActionFact {
329    RenameTo { new_name: Ident },
330}
331
332#[derive(Clone, Debug, PartialEq)]
333pub struct CreateTypeFact {
334    pub name: QualifiedName,
335    pub kind: TypeCreationKind,
336}
337
338#[derive(Clone, Debug, PartialEq)]
339pub struct AlterTypeFact {
340    pub name: QualifiedName,
341    pub actions: Vec<AlterTypeActionFact>,
342}
343
344#[derive(Clone, Debug, PartialEq)]
345pub enum AlterTypeActionFact {
346    RenameTo {
347        new_name: Ident,
348    },
349    SetSchema {
350        new_schema: String,
351    },
352    AddValue {
353        new_value: String,
354        neighbor: Option<String>,
355        before: bool,
356    },
357    RenameValue {
358        old_value: String,
359        new_value: String,
360    },
361}
362
363#[derive(Clone, Debug, PartialEq, Default)]
364pub enum RoleFact {
365    #[default]
366    Unknown,
367    Named {
368        name: String,
369        via_legacy_group_syntax: bool,
370    },
371    CurrentUser,
372    CurrentRole,
373    SessionUser,
374}
375
376#[derive(Clone, Debug, PartialEq)]
377pub struct CreateRoleFact {
378    pub name: String,
379    pub inherits: bool,
380    pub can_login: bool,
381}
382
383#[derive(Clone, Debug, PartialEq)]
384pub struct AlterRoleFact {
385    pub name: RoleFact,
386    pub inherits: Option<bool>,
387}
388
389#[derive(Clone, Debug, PartialEq)]
390pub struct DropRoleFact {
391    pub names: Vec<String>,
392    pub if_exists: bool,
393}
394
395#[derive(Clone, Debug, PartialEq)]
396pub struct CreateFunctionFact {
397    pub name: QualifiedName,
398    pub or_replace: bool,
399    pub params: Vec<ParamFact>,
400    pub return_type: Option<RetTypeFact>,
401    pub options: Vec<FuncOptionFact>,
402}
403
404#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
405pub struct ParamFact {
406    pub mode: ParamModeFact,
407    pub name: Option<String>,
408    pub ty: String,
409    pub default: Option<ExprIr>,
410}
411
412#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
413pub enum ParamModeFact {
414    In,
415    Out,
416    InOut,
417    Variadic,
418}
419
420#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
421pub enum RetTypeFact {
422    Table(Vec<ColumnFact>),
423    Scalar(String),
424}
425
426#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
427pub enum FuncOptionFact {
428    Language(String),
429    Volatility(VolatilityKind),
430    Security(SecurityKind),
431    Strict(StrictKind),
432    Leakproof(bool),
433    Parallel(String),
434    Cost,
435    Rows,
436    Reset(String),
437    As {
438        definition: Option<String>,
439        obj_file: Option<String>,
440        link_symbol: Option<String>,
441    },
442    Transform,
443    Window,
444    Support,
445    Unknown,
446}
447
448#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
449pub enum VolatilityKind {
450    Immutable,
451    Stable,
452    Volatile,
453}
454#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
455pub enum SecurityKind {
456    Invoker,
457    Definer,
458}
459#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
460pub enum StrictKind {
461    Strict,
462    CalledOnNull,
463    ReturnsNullOnNull,
464}
465
466#[derive(Clone, Debug, PartialEq)]
467pub struct AlterFunctionFact {
468    pub name: QualifiedName,
469    pub params: Vec<String>,
470    pub action: AlterFunctionAction,
471}
472
473#[derive(Clone, Debug, PartialEq)]
474pub enum AlterFunctionAction {
475    Rename { from: String, to: String },
476    OwnerChange(RoleFact),
477    SchemaChange { new_schema: String },
478    DependsOnExtension { extension: String },
479    NoDependsOnExtension { extension: String },
480    OptionsChange(Vec<FuncOptionFact>),
481}
482
483#[derive(Clone, Debug, PartialEq)]
484pub struct DropFunctionFact {
485    pub signatures: Vec<FunctionSigFact>,
486    pub if_exists: bool,
487    pub cascade: bool,
488}
489
490#[derive(Clone, Debug, PartialEq)]
491pub struct FunctionSigFact {
492    pub name: QualifiedName,
493    pub params: Vec<String>,
494}
495
496#[derive(Clone, Debug, PartialEq)]
497pub struct CreateProcedureFact {
498    pub name: QualifiedName,
499    pub or_replace: bool,
500    pub params: Vec<ParamFact>,
501    pub options: Vec<FuncOptionFact>,
502}
503
504#[derive(Clone, Debug, PartialEq)]
505pub struct AlterProcedureFact {
506    pub name: QualifiedName,
507    pub params: Vec<String>,
508    pub action: AlterFunctionAction,
509}
510
511#[derive(Clone, Debug, PartialEq)]
512pub struct DropProcedureFact {
513    pub signatures: Vec<FunctionSigFact>,
514    pub if_exists: bool,
515    pub cascade: bool,
516}
517
518#[derive(Clone, Debug, PartialEq)]
519pub struct CreateAggregateFact {
520    pub name: QualifiedName,
521    pub or_replace: bool,
522    pub params: Vec<ParamFact>,
523}
524
525#[derive(Clone, Debug, PartialEq)]
526pub struct AlterAggregateFact {
527    pub name: QualifiedName,
528    pub params: Vec<String>,
529    pub action: AlterFunctionAction,
530}
531
532#[derive(Clone, Debug, PartialEq)]
533pub struct DropAggregateFact {
534    pub signatures: Vec<FunctionSigFact>,
535    pub if_exists: bool,
536    pub cascade: bool,
537}
538
539#[derive(Clone, Debug, PartialEq)]
540pub struct CreatePublicationFact {
541    pub name: String,
542    pub scope: PublicationScope,
543    pub params: Vec<AttributeFact>,
544}
545
546#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
547pub enum PublicationScope {
548    AllTables { except: Vec<String> },
549    Explicit(Vec<PublicationObjectFact>),
550}
551
552#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
553pub enum PublicationObjectFact {
554    Table {
555        name: QualifiedName,
556        only: bool,
557        include_partitions: bool,
558        columns: Option<Vec<String>>,
559        row_filter: Option<PublicationRowFilter>,
560    },
561    SchemaTables {
562        schema: String,
563        row_filter: Option<PublicationRowFilter>,
564    },
565    CurrentSchemaShorthand,
566    Unknown,
567}
568
569#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
570pub enum PublicationRowFilter {
571    Parsed(ExprIr),
572    CatalogSql(String),
573}
574
575#[derive(Clone, Debug, PartialEq)]
576pub struct AlterPublicationFact {
577    pub name: String,
578    pub action: AlterPublicationActionFact,
579}
580
581#[derive(Clone, Debug, PartialEq)]
582pub enum AlterPublicationActionFact {
583    AddObjects(Vec<PublicationObjectFact>),
584    SetObjects(PublicationScope),
585    DropObjects(Vec<PublicationObjectFact>),
586    SetOptions(Vec<AttributeFact>),
587    OwnerChange(RoleFact),
588    Rename { to: String },
589}
590
591#[derive(Clone, Debug, PartialEq)]
592pub struct DropPublicationFact {
593    pub names: Vec<String>,
594    pub if_exists: bool,
595    pub cascade: bool,
596}
597
598#[derive(Clone, Debug, PartialEq)]
599pub struct CreateSubscriptionFact {
600    pub name: Option<String>,
601    pub connection: ConnectionTarget,
602    pub publications: Vec<String>,
603    pub params: Option<Vec<AttributeFact>>,
604}
605
606#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
607pub enum ConnectionTarget {
608    Literal(Option<String>),
609    Server(Option<String>),
610    /// A synchronized subscription exists, but its connection string is never
611    /// read from PostgreSQL or written to the cache.
612    Redacted,
613}
614
615#[derive(Clone, Debug, PartialEq)]
616pub struct AlterSubscriptionFact {
617    pub name: String,
618    pub action: AlterSubscriptionActionFact,
619}
620
621#[derive(Clone, Debug, PartialEq)]
622pub enum SubscriptionPublicationMode {
623    Set,
624    Add,
625    Drop,
626}
627
628#[derive(Clone, Debug, PartialEq)]
629pub enum AlterSubscriptionActionFact {
630    SetConnection(ConnectionTarget),
631    Publications {
632        mode: SubscriptionPublicationMode,
633        publications: Vec<String>,
634        params: Vec<AttributeFact>,
635    },
636    RefreshPublication(Vec<AttributeFact>),
637    SetEnabled(bool),
638    SetOptions(Vec<AttributeFact>),
639    SetServer(Option<String>),
640    Skip(Vec<AttributeFact>),
641    OwnerChange(RoleFact),
642    Rename {
643        to: String,
644    },
645}
646
647#[derive(Clone, Debug, PartialEq)]
648pub struct DropSubscriptionFact {
649    pub name: String,
650    pub if_exists: bool,
651}
652
653#[derive(Clone, Debug, PartialEq)]
654pub struct GrantFact {
655    pub privileges: PrivilegeSpec,
656    pub target: GrantTarget,
657    pub grantees: Vec<RoleFact>,
658    pub with_grant_option: bool,
659    pub granted_by: Option<RoleFact>,
660}
661
662#[derive(Clone, Debug, PartialEq)]
663pub struct RevokeFact {
664    pub grant_option_only: bool,
665    pub privileges: PrivilegeSpec,
666    pub target: GrantTarget,
667    pub revokees: Vec<RoleFact>,
668    pub granted_by: Option<RoleFact>,
669    pub cascade: bool,
670}
671
672#[derive(Clone, Debug, PartialEq)]
673pub enum PrivilegeSpec {
674    All,
675    List(Vec<PrivilegeFact>),
676}
677
678#[derive(Clone, Debug, PartialEq)]
679pub enum PrivilegeFact {
680    Select,
681    Insert,
682    Update,
683    Delete,
684    Truncate,
685    References,
686    Trigger,
687    Maintain,
688    Execute,
689    Create,
690    Temporary,
691    AlterSystem,
692    All,
693    Named(String),
694    RoleMembership(String),
695    Unknown,
696}
697
698#[derive(Clone, Debug, PartialEq)]
699pub enum GrantTarget {
700    Tables(Vec<QualifiedName>),
701    AllTablesInSchema(Vec<String>),
702}
703
704#[derive(Clone, Debug, PartialEq)]
705pub struct CreateDatabaseFact {
706    pub name: String,
707    pub options: Vec<DatabaseOptionFact>,
708}
709
710#[derive(Clone, Debug, PartialEq)]
711pub enum DatabaseOptionFact {
712    Owner(DatabaseOptionValue),
713    Template(DatabaseOptionValue),
714    Encoding(DatabaseOptionValue),
715    Tablespace(DatabaseOptionValue),
716    ConnectionLimit(DatabaseOptionValue),
717    Named(String, DatabaseOptionValue),
718    Unknown(DatabaseOptionValue),
719}
720
721#[derive(Clone, Debug, PartialEq)]
722pub enum DatabaseOptionValue {
723    Default,
724    Literal(Option<String>),
725}
726
727#[derive(Clone, Debug, PartialEq)]
728pub struct AlterDatabaseFact {
729    pub name: QualifiedName,
730    pub action: AlterDatabaseAction,
731}
732
733#[derive(Clone, Debug, PartialEq)]
734pub enum AlterDatabaseAction {
735    Rename { to: String },
736    OwnerChange(RoleFact),
737    TablespaceChange { new_tablespace: String },
738    SetConfigParam { param: String },
739    ResetConfigParam { param: Option<String> },
740    RefreshCollationVersion,
741    OptionChanges(Vec<DatabaseOptionFact>),
742}
743
744#[derive(Clone, Debug, PartialEq)]
745pub struct DropDatabaseFact {
746    pub name: QualifiedName,
747    pub if_exists: bool,
748}
749
750#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
751pub struct AttributeFact {
752    pub name: String,
753    pub value: String,
754}
755
756#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
757pub enum ColumnGeneration {
758    Ordinary,
759    Serial,
760    Identity,
761}
762
763#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
764pub struct ColumnFact {
765    pub name: String,
766    pub ty: Option<String>,
767    pub not_null: bool,
768    pub is_primary_key: bool,
769    pub primary_key_constraint_name: Option<String>,
770    pub is_unique: bool,
771    pub unique_constraint_name: Option<String>,
772    pub default: Option<ExprIr>,
773    pub generation: ColumnGeneration,
774}
775
776#[derive(Clone, Debug, PartialEq)]
777pub struct FkFact {
778    pub constraint_name: Option<String>,
779    pub references: QualifiedName,
780    pub from_columns: Vec<String>,
781    pub to_columns: Vec<String>,
782}
783
784#[derive(Clone, Debug, PartialEq)]
785pub enum TableConstraintFact {
786    PrimaryKey {
787        constraint_name: Option<String>,
788        columns: Vec<String>,
789    },
790    Unique {
791        constraint_name: Option<String>,
792        columns: Vec<String>,
793    },
794    Check {
795        constraint_name: Option<String>,
796    },
797    Exclude {
798        constraint_name: Option<String>,
799    },
800}
801
802#[derive(Clone, Debug, PartialEq)]
803pub enum AlterDomainActionFact {
804    AddConstraint,
805    DropConstraint,
806    DropDefault,
807    DropNotNull,
808    OwnerChange,
809    RenameConstraint,
810    RenameTo,
811    SetDefault,
812    SetNotNull,
813    SetSchema,
814    ValidateConstraint,
815}
816
817#[derive(Clone, Debug, PartialEq)]
818pub enum AlterTableActionFact {
819    AddColumn {
820        name: String,
821        ty: Option<String>,
822        if_not_exists: bool,
823        not_null: bool,
824        default: Option<ExprIr>,
825        generation: ColumnGeneration,
826    },
827    DropColumn {
828        name: String,
829        if_exists: bool,
830        cascade: bool,
831    },
832    RenameColumn {
833        from: Ident,
834        to: Ident,
835    },
836    RenameTo {
837        new_name: Ident,
838    },
839    AddForeignKey {
840        constraint_name: Option<String>,
841        references: QualifiedName,
842        from_columns: Vec<String>,
843        to_columns: Vec<String>,
844        not_valid: bool,
845    },
846    AlterConstraint {
847        name: Option<String>,
848        deferrable: bool,
849    },
850    RenameConstraint {
851        old_name: String,
852        new_name: String,
853    },
854    DropConstraint {
855        name: String,
856        if_exists: bool,
857        cascade: bool,
858    },
859    AddCheckConstraint {
860        constraint_name: Option<String>,
861        not_valid: bool,
862    },
863    AddUniqueConstraint {
864        constraint_name: Option<String>,
865        columns: Vec<String>,
866        using_index: Option<QualifiedName>,
867    },
868    AddPrimaryKeyConstraint {
869        constraint_name: Option<String>,
870        columns: Vec<String>,
871        using_index: Option<QualifiedName>,
872    },
873    AddExcludeConstraint {
874        constraint_name: Option<String>,
875    },
876    SetNotNull {
877        column: String,
878    },
879    DropNotNull {
880        column: String,
881    },
882    SetType {
883        column: String,
884        ty: String,
885        has_using: bool,
886    },
887    SetDefault {
888        column: String,
889        default: Option<ExprIr>,
890    },
891    SetExpression {
892        column: String,
893        expr: ExprIr,
894    },
895    SetOptions {
896        column: String,
897        attributes: Vec<AttributeFact>,
898    },
899    Inherit {
900        column: String,
901        parent: QualifiedName,
902    },
903    NoInherit {
904        column: String,
905        parent: QualifiedName,
906    },
907    ValidateConstraint {
908        constraint_name: String,
909    },
910    DisableTrigger {
911        trigger_name: Option<String>,
912    },
913    EnableTrigger {
914        trigger_name: Option<String>,
915    },
916    AttachPartition {
917        child: QualifiedName,
918        strategy: Option<String>,
919    },
920    DetachPartition {
921        child: QualifiedName,
922    },
923    SetStorage {
924        column: String,
925    },
926    SetAccessMethod,
927    ClusterOn {
928        index: String,
929    },
930    InheritTable {
931        parent: QualifiedName,
932    },
933    NoInheritTable {
934        parent: QualifiedName,
935    },
936    MergePartitions {
937        parent: QualifiedName,
938    },
939    SplitPartition,
940    SetSchema {
941        new_schema: String,
942    },
943    SetTablespace {
944        tablespace: String,
945    },
946    SetLogged,
947    SetUnlogged,
948    OwnerTo {
949        new_owner: RoleFact,
950    },
951    ReplicaIdentity {
952        option: String,
953    },
954    ForceRls,
955    EnableRls,
956    DisableRls,
957    EnableAlwaysTrigger {
958        trigger_name: Option<String>,
959    },
960    EnableReplicaTrigger {
961        trigger_name: Option<String>,
962    },
963}