//private HintSet GetSchemaHints(StorageModel extractedSchema, StorageModel targetSchema) //{ // context.SchemaHints = new HintSet(extractedSchema, targetSchema); // if (context.Stage==UpgradeStage.Upgrading) // BuildSchemaHints(extractedSchema); // return context.SchemaHints; //} private void BuildSchemaHints(StorageModel extractedSchema, UpgradeHintsProcessingResult result, StoredDomainModel currentDomainModel) { var oldModel = context.ExtractedDomainModel; if (oldModel == null) { return; } var handlers = Domain.Demand().Handlers; // It's important to use same StoredDomainModel of current domain // in both UpgradeHintsProcessor and HintGenerator instances. var hintGenerator = new HintGenerator(result.TypeMapping, result.ReverseTypeMapping, result.FieldMapping, result.Hints, handlers, context.Services.MappingResolver, extractedSchema, currentDomainModel, oldModel); var hints = hintGenerator.Run(); context.UpgradedTypesMapping = hints.UpgradedTypesMapping; context.Hints.Clear(); foreach (var modelHint in hints.ModelHints) { context.Hints.Add(modelHint); } foreach (var schemaHint in hints.SchemaHints) { try { context.SchemaHints.Add(schemaHint); } catch (Exception error) { UpgradeLog.Warning(Strings.LogFailedToAddSchemaHintXErrorY, schemaHint, error); } } }
/// <inheritdoc/> protected override IPathNode VisitFullTextIndexInfo(FullTextIndexInfo fullTextIndex) { if (!providerInfo.Supports(ProviderFeatures.FullText)) { UpgradeLog.Warning(Strings.LogFullTextIndexesAreNotSupportedByCurrentStorageIgnoringIndexX, fullTextIndex.Name); return(null); } var table = GetTable(fullTextIndex.PrimaryIndex.ReflectedType); var primaryIndex = table.PrimaryIndex; var ftIndex = new StorageFullTextIndexInfo(table, fullTextIndex.Name); foreach (var fullTextColumn in fullTextIndex.Columns) { var column = table.Columns[fullTextColumn.Name]; string typeColumn = null; if (providerInfo.Supports(ProviderFeatures.FullTextColumnDataTypeSpecification)) { if (fullTextColumn.TypeColumn != null) { typeColumn = table.Columns[fullTextColumn.TypeColumn.Name].Name; } } else { UpgradeLog.Warning(Strings.LogSpecificationOfTypeColumnForFulltextColumnIsNotSupportedByCurrentStorageIgnoringTypeColumnSpecificationForColumnX, fullTextColumn.Column.Name); } new FullTextColumnRef(ftIndex, column, fullTextColumn.Configuration, typeColumn); } ftIndex.FullTextCatalog = fulltextCatalogNameBuilder.Build(fullTextIndex.PrimaryIndex.ReflectedType, table); ftIndex.ChangeTrackingMode = configuration.FullTextChangeTrackingMode; return(ftIndex); }
private static async Task ExtractMetadataAsync( UpgradeServiceAccessor services, SqlExecutor executor, SqlWorkerResult result, SqlWorkerTask task, CancellationToken token) { var set = new MetadataSet(); var mapping = new MetadataMapping(services.StorageDriver, services.NameBuilder); var metadataExtractor = new MetadataExtractor(mapping, executor); foreach (var metadataTask in services.MappingResolver.GetMetadataTasks() .Where(metadataTask => !ShouldSkipMetadataExtraction(mapping, result, metadataTask))) { try { if (task.HasFlag(SqlWorkerTask.ExtractMetadataAssemblies)) { await metadataExtractor.ExtractAssembliesAsync(set, metadataTask, token).ConfigureAwait(false); } if (task.HasFlag(SqlWorkerTask.ExtractMetadataTypes)) { await metadataExtractor.ExtractTypesAsync(set, metadataTask, token).ConfigureAwait(false); } if (task.HasFlag(SqlWorkerTask.ExtractMetadataExtension)) { await metadataExtractor.ExtractExtensionsAsync(set, metadataTask, token).ConfigureAwait(false); } } catch (Exception exception) { UpgradeLog.Warning( Strings.LogFailedToExtractMetadataFromXYZ, metadataTask.Catalog, metadataTask.Schema, exception); } } result.Metadata = set; }
private void ParseStoredDomainModel() { var context = UpgradeContext; var extensions = context.Metadata.Extensions.Where(e => e.Name == WellKnown.DomainModelExtensionName); try { var found = false; var types = new List <StoredTypeInfo>(); foreach (var extension in extensions) { found = true; var part = StoredDomainModel.Deserialize(extension.Value); types.AddRange(part.Types); } if (!found) { UpgradeLog.Info(Strings.LogDomainModelIsNotFoundInStorage); return; } var model = new StoredDomainModel { Types = types.ToArray() }; model.UpdateReferences(); context.ExtractedDomainModel = model; } catch (Exception e) { UpgradeLog.Warning(e, Strings.LogFailedToExtractDomainModelFromStorage); } }
private bool EnsureTableExist(StoredTypeInfo type) { var nodeName = GetTableName(type); if (extractedStorageModel.Tables.Contains(nodeName)) { return(true); } UpgradeLog.Warning(Strings.ExTableXIsNotFound, nodeName); return(false); }
public void UpgradeLogTest() { if (File.Exists(filePath)) { File.Delete(filePath); } UpgradeLog.Debug("Test message", null); UpgradeLog.Debug("Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Debug("Test message", new object[] { 1 }); UpgradeLog.Debug("Test message {0}", null); UpgradeLog.Debug(new Exception("Some exeption")); UpgradeLog.Debug(null, new object[] { 1 }); UpgradeLog.Info("Test message", null); UpgradeLog.Info("Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Info("Test message", new object[] { 1 }); UpgradeLog.Info("Test message {0}", null); UpgradeLog.Info(new Exception("Some exeption")); UpgradeLog.Info(null, new object[] { 1 }); UpgradeLog.Warning("Test message", null); UpgradeLog.Warning("Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Warning("Test message", new object[] { 1 }); UpgradeLog.Warning("Test message {0}", null); UpgradeLog.Warning(new Exception("Some exeption")); UpgradeLog.Warning(null, new object[] { 1 }); UpgradeLog.Error("Test message", null); UpgradeLog.Error("Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 }); UpgradeLog.Error("Test message", new object[] { 1 }); UpgradeLog.Error("Test message {0}", null); UpgradeLog.Error(new Exception("Some exeption")); UpgradeLog.Error(null, new object[] { 1 }); UpgradeLog.FatalError("Test message", null); UpgradeLog.FatalError("Test message with parameter {0}", new object[] { 1 }); UpgradeLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 }); UpgradeLog.FatalError("Test message", new object[] { 1 }); UpgradeLog.FatalError("Test message {0}", null); UpgradeLog.FatalError(new Exception("Some exeption")); UpgradeLog.FatalError(null, new object[] { 1 }); Assert.IsTrue(File.Exists(filePath)); Assert.AreEqual(File.ReadAllLines(filePath).Count(), 35); }
private bool EnsureFieldExist(StoredTypeInfo type, string fieldName) { if (!EnsureTableExist(type)) { return(false); } var nodeName = GetTableName(type); var actualFieldName = nameBuilder.ApplyNamingRules(fieldName); if (extractedStorageModel.Tables[nodeName].Columns.Contains(actualFieldName)) { return(true); } UpgradeLog.Warning(Strings.ExColumnXIsNotFoundInTableY, actualFieldName, nodeName); return(false); }
private SecondaryIndexInfo CreateSecondaryIndex(TableInfo owningTable, string indexName, IndexInfo originalModelIndex) { var index = new SecondaryIndexInfo(owningTable, indexName); if (originalModelIndex.Filter != null) { if (providerInfo.Supports(ProviderFeatures.PartialIndexes)) { index.Filter = new PartialIndexFilterInfo(compiler.Compile(handlers, originalModelIndex)); } else { UpgradeLog.Warning( Strings.LogStorageXDoesNotSupportPartialIndexesIgnoringFilterForPartialIndexY, providerInfo.ProviderName, originalModelIndex); } } return(index); }