@@ -39,16 +39,25 @@ func init() {
3939 "transient-check-constraint" , "column-type" ,
4040 func (from , to NodeVars ) rel.Clauses {
4141 colID := rel .Var ("columnID" )
42+ tableID := rel .Var ("table-id" )
43+ oldColumnType := MkNodeVars ("old-column-type" )
4244 return rel.Clauses {
4345 from .Type ((* scpb .CheckConstraint )(nil )),
4446 to .Type ((* scpb .ColumnType )(nil )),
45- JoinOnDescID (from , to , "table-id" ),
47+ JoinOnDescID (from , to , tableID ),
4648 to .El .AttrEqVar (screl .ColumnID , colID ),
4749 from .ReferencedColumnIDsContains (colID ),
4850 from .TargetStatus (scpb .TransientAbsent ),
4951 to .TargetStatus (scpb .ToPublic ),
5052 from .CurrentStatus (scpb .Status_TRANSIENT_VALIDATED ),
5153 to .CurrentStatus (scpb .Status_PUBLIC ),
54+ // Only apply this rule if there's an old column type being dropped,
55+ // which indicates this is an ALTER COLUMN TYPE operation.
56+ oldColumnType .Type ((* scpb .ColumnType )(nil )),
57+ oldColumnType .El .AttrEqVar (screl .DescID , tableID ),
58+ oldColumnType .El .AttrEqVar (screl .ColumnID , colID ),
59+ oldColumnType .TargetStatus (scpb .ToAbsent ),
60+ oldColumnType .JoinTargetNode (),
5261 }
5362 },
5463 )
0 commit comments