Beispiel #1
0
        public void UpgradeSchema(SchemaExtractionResult extractedSchema,
                                  StorageModel sourceModel, StorageModel targetModel, ActionSequence upgradeActions)
        {
            var enforceChangedColumns = context.Hints
                                        .OfType <ChangeFieldTypeHint>()
                                        .SelectMany(hint => hint.AffectedColumns)
                                        .ToList();

            var skipConstraints = context.Stage == UpgradeStage.Upgrading;

            var translator = new SqlActionTranslator(
                session.Handlers, executor, context.Services.MappingResolver,
                upgradeActions, extractedSchema, sourceModel, targetModel,
                enforceChangedColumns, !skipConstraints);

            var result = translator.Translate();

            if (SqlLog.IsLogged(LogLevel.Info))
            {
                LogStatements(result);
            }

            foreach (var handler in context.OrderedUpgradeHandlers)
            {
                handler.OnBeforeExecuteActions(result);
            }

            result.ProcessWith(statementProcessor, ExecuteNonTransactionally);
        }
Beispiel #2
0
        private UpgradeActionSequence TranslateActions(SchemaExtractionResult extractedSchema, StorageModel sourceModel,
                                                       StorageModel targetModel, ActionSequence upgradeActions)
        {
            var enforceChangedColumns = context.Hints
                                        .OfType <ChangeFieldTypeHint>()
                                        .SelectMany(hint => hint.AffectedColumns)
                                        .ToList();

            var skipConstraints = context.Stage == UpgradeStage.Upgrading;

            var translator = new SqlActionTranslator(
                session.Handlers, executor, context.Services.MappingResolver,
                upgradeActions, extractedSchema, sourceModel, targetModel,
                enforceChangedColumns, !skipConstraints);

            var result = translator.Translate();

            if (SqlLog.IsLogged(LogLevel.Info))
            {
                LogStatements(result);
            }

            return(result);
        }