public IStatement[] PrepareAll(DatabaseConnection connection, List <string> sql) { var length = sql.Count; var result = new IStatement[length]; for (var i = 0; i < length; i++) { result[i] = connection.PrepareStatement(sql[i]); } return(result); }
public void UpdateVersion(DatabaseConnection connection, bool dbJustCreated) { if (dbJustCreated) { connection.Execute($"PRAGMA user_version = {DbVersion};"); return; } int version; using (var versionStatement = connection.PrepareStatement("PRAGMA user_version;")) { version = versionStatement.ExecuteQuery().FirstOrDefault().GetInt(0); } if (version >= DbVersion) { return; } _logger.LogInformation($"InfuseSync: DB version {version} is outdated. Will migrate to version {DbVersion}."); for (var migrateVersion = version; migrateVersion < DbVersion; ++migrateVersion) { var migration = migrations[migrateVersion]; if (migration != null) { _logger.LogInformation($"InfuseSync: Performing migration for DB version {migrateVersion}."); migration.Migrate(connection); } else { _logger.LogInformation($"InfuseSync: Migration not found for DB version {migrateVersion}."); } } connection.Execute($"PRAGMA user_version = {DbVersion};"); _logger.LogInformation($"InfuseSync: DB migration finished."); }
public IStatement PrepareStatement(DatabaseConnection connection, string sql) { return(connection.PrepareStatement(sql)); }