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