Exemplo n.º 1
0
 protected void EnsureSchemaCreated()
 {
     if (!DatabaseUtils.SchemaExists(ConnectionString, TimeoutSecs, SchemaName))
     {
         DatabaseUtils.CreateSchema(ConnectionString, TimeoutSecs, SchemaName);
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }