protected void EnsureSchemaCreated() { if (!DatabaseUtils.SchemaExists(ConnectionString, TimeoutSecs, SchemaName)) { DatabaseUtils.CreateSchema(ConnectionString, TimeoutSecs, SchemaName); } }
public static void EnsureExist(string connectionString, int timeoutSecs) { _log.DebugFormat("Checking existence of history tables in schema: {0}", HistorySchema.HistorySchemaName); if (!DatabaseUtils.SchemaExists(connectionString, timeoutSecs, HistorySchema.HistorySchemaName)) { DatabaseUtils.CreateSchema(connectionString, timeoutSecs, HistorySchema.HistorySchemaName); } var b = HistoryTablesBuilder.Get(); var tables = b.GetTables(); var tablesInHistorySchema = DatabaseUtils.GetTablesInSchema( connectionString, timeoutSecs, false, HistorySchema.HistorySchemaName); var builder = new Builder(); foreach (var t in tables) { if (!tablesInHistorySchema.Contains(t.Name)) { builder.AddTable(t); } } if (builder.HasTables) { _log.WarnFormat("Recreating missing history tables in schema: {0}", HistorySchema.HistorySchemaName); builder.Execute(connectionString, timeoutSecs); } }
private static void EnsureAllStagingTablesExist(string connectionString, int timeoutSecs, string schemaName) { _log.DebugFormat("Checking existence of staging tables in schema: {0}", schemaName); if (!DatabaseUtils.SchemaExists(connectionString, timeoutSecs, schemaName)) { DatabaseUtils.CreateSchema(connectionString, timeoutSecs, schemaName); } var b = StagingTablesBuilder.Get(schemaName); var tables = b.GetTables(); var tablesInPrimaryStage = DatabaseUtils.GetTablesInSchema( connectionString, timeoutSecs, false, StagingSchema.PrimaryStagingSchemaName); var builder = new Builder(); foreach (var t in tables) { if (!tablesInPrimaryStage.Contains(t.Name)) { builder.AddTable(t); } } if (builder.HasTables) { _log.WarnFormat("Recreating missing staging tables in schema: {0}", schemaName); builder.Execute(connectionString, timeoutSecs); } }