code: def CheckForeignKeysWrapper(conn):
      
      yield
      cur = conn.cursor()
      cur.execute('PRAGMA foreign_key_check')
      errors = cur.fetchall()
      if errors:
          raise ForeignKeyError(errors)
docs: Migration wrapper that checks foreign keys.
  
      Note that this may raise different exceptions depending on the
      underlying database API.