private static async Task InstanceSchemaRecordCreatedAsync(string connectionString, CancellationToken cancellationToken) { if (!await SchemaDataStore.InstanceSchemaRecordExistsAsync(connectionString, cancellationToken)) { throw new SchemaManagerException(Resources.InstanceSchemaRecordErrorMessage); } }
private static async Task UpgradeSchemaAsync(string connectionString, int version, string script, CancellationToken cancellationToken) { // check if the record for given version exists in failed status await SchemaDataStore.DeleteSchemaVersionAsync(connectionString, version, SchemaDataStore.Failed, cancellationToken); await SchemaDataStore.ExecuteScriptAndCompleteSchemaVersionAsync(connectionString, script, version, cancellationToken); Console.WriteLine(string.Format(Resources.SchemaMigrationSuccessMessage, version)); }
private static async Task FetchUpdatedAvailableVersionsAsync(ISchemaClient schemaClient, string connectionString, CancellationToken cancellationToken) { availableVersions = await schemaClient.GetAvailabilityAsync(cancellationToken); availableVersions.Sort((x, y) => x.Id.CompareTo(y.Id)); if (availableVersions.First().Id != await SchemaDataStore.GetCurrentSchemaVersionAsync(connectionString, cancellationToken)) { throw new SchemaManagerException(Resources.AvailableVersionsErrorMessage); } }
public static async Task EnsureBaseSchemaExistsAsync(string connectionString, CancellationToken cancellationToken) { IBaseScriptProvider baseScriptProvider = new BaseScriptProvider(); await InitializeAsync(connectionString, cancellationToken); if (!await SchemaDataStore.BaseSchemaExistsAsync(connectionString, cancellationToken)) { var script = baseScriptProvider.GetScript(); Console.WriteLine(Resources.BaseSchemaExecuting); await SchemaDataStore.ExecuteScript(connectionString, script, cancellationToken); Console.WriteLine(Resources.BaseSchemaSuccess); } else { Console.WriteLine(Resources.BaseSchemaAlreadyExists); } }