code: def get_current_head(graph):
      
      session = new_session(graph)
      try:
          result = session.execute("SELECT version_num FROM alembic_version")
      except ProgrammingError:
          return None
      else:
          return result.scalar()
      finally:
          session.close()
docs: Get the current database head revision, if any.