protected IEnumerator CheckForUpdates() { var targetVersion = this.config.Version; var versionKey = this.config.VersionPrefsKey; var currentVersion = PlayerPrefs.GetInt(versionKey); if (currentVersion == targetVersion) { yield break; } //Open connection: var connectionUri = SqliteUtils.GetConnectionUri(this.config.DatabaseName); var connection = new SqliteConnection(connectionUri); connection.Open(); if (connection.State != ConnectionState.Open) { throw new Exception($"Can't connect to db {connectionUri}!"); } //Update database version: for (var version = currentVersion + Int.ONE; version <= targetVersion; version++) { var hasError = new Reference <bool>(); yield return(this.UpdateDatabase(version, connection, hasError)); if (hasError.value) { connection.Close(); connection.Dispose(); throw new Exception($"Can't update db to {version} version!"); } PlayerPrefs.SetInt(versionKey, targetVersion); } //Close connection: connection.Close(); connection.Dispose(); }