@@ -96,19 +96,23 @@ func init() {
9696 )
9797}
9898
99- // These rules ensure that a non-indexed backed constraint with a column
100- // name in its expression is cleaned up before the column is dropped.
99+ // These rules ensure that a unique without index constraint with a column
100+ // name in its expression is cleaned up before the column name is dropped.
101+ // This is needed because unique without index constraints can have predicates
102+ // that reference columns by name.
101103func init () {
102104 registerDepRuleForDrop (
103- "non-indexed backed constraint should be cleaned up " +
104- "before column name references" ,
105+ "unique without index constraint should be cleaned up before column name references" ,
105106 scgraph .Precedence ,
106107 "constraint" , "referenced-column-name" ,
107108 scpb .Status_ABSENT , scpb .Status_ABSENT ,
108109 func (from , to NodeVars ) rel.Clauses {
109110 fromColumnID := rel .Var ("fromColumnID" )
110111 return rel.Clauses {
111- from .TypeFilter (rulesVersionKey , isNonIndexBackedConstraint , isWithExpression ),
112+ from .Type (
113+ (* scpb .UniqueWithoutIndexConstraint )(nil ),
114+ (* scpb .UniqueWithoutIndexConstraintUnvalidated )(nil ),
115+ ),
112116 from .ReferencedColumnIDsContains (fromColumnID ),
113117 to .Type ((* scpb .ColumnName )(nil )),
114118 to .El .AttrEqVar (screl .ColumnID , fromColumnID ),
0 commit comments