sql:=fmt.Sprintf("SELECT Name FROM SYS.DEFAULT_CONSTRAINTS WHERE PARENT_OBJECT_ID = OBJECT_ID('%[1]s') AND PARENT_COLUMN_ID IN (SELECT column_id FROM sys.columns WHERE lower(NAME) IN (%[2]s) AND object_id = OBJECT_ID('%[1]s'))",
tableName,strings.Replace(cols,"`","'",-1))
constraints:=make([]string,0)
iferr:=sess.SQL(sql).Find(&constraints);err!=nil{
sess.Rollback()
returnfmt.Errorf("Find constraints: %v",err)
}
for_,constraint:=rangeconstraints{
if_,err:=sess.Exec(fmt.Sprintf("ALTER TABLE `%s` DROP CONSTRAINT `%s`",tableName,constraint));err!=nil{