code: def table_has_constraint(table, name, db):
      
      t = sa.Table(table, db.metadata, autoload=True, autoload_with=db.engine)
  
      for c in t.constraints:
          if c.name == name:
              return True
      return False
docs: Utility to find a constraint name in alembic migrations