public MigrationRunner(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssemblies = assemblies;
            _announcer = runnerContext.Announcer;
            Processor = processor;
            _stopWatch = runnerContext.StopWatch;
            RunnerContext = runnerContext;

            SilentlyFail = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;

            _migrationScopeHandler = new MigrationScopeHandler(Processor);
            _migrationValidator = new MigrationValidator(_announcer, Conventions);
            MigrationLoader = new DefaultMigrationInformationLoader(Conventions, _migrationAssemblies, runnerContext.Namespace, runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader = new ProfileLoader(runnerContext, this, Conventions);
            MaintenanceLoader = new MaintenanceLoader(_migrationAssemblies, runnerContext.Tags, Conventions);

            if (runnerContext.NoConnection){
                VersionLoader = new ConnectionlessVersionLoader(this, _migrationAssemblies, Conventions, runnerContext.StartVersion, runnerContext.Version);
            }
            else{
                VersionLoader = new VersionLoader(this, _migrationAssemblies, Conventions);
            }
        }
Beispiel #2
0
        public MigrationRunner(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssemblies  = assemblies;
            _announcer            = runnerContext.Announcer;
            Processor             = processor;
            _stopWatch            = runnerContext.StopWatch;
            ApplicationContext    = runnerContext.ApplicationContext;
            TransactionPerSession = runnerContext.TransactionPerSession;

            SilentlyFail     = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
            {
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;
            }

            _migrationScopeHandler = new MigrationScopeHandler(Processor);
            _migrationValidator    = new MigrationValidator(_announcer, Conventions);
            MigrationLoader        = new DefaultMigrationInformationLoader(Conventions, _migrationAssemblies, runnerContext.Namespace, runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader          = new ProfileLoader(runnerContext, this, Conventions);
            MaintenanceLoader      = new MaintenanceLoader(_migrationAssemblies, runnerContext.Tags, Conventions);

            if (runnerContext.NoConnection)
            {
                VersionLoader = new ConnectionlessVersionLoader(this, _migrationAssemblies, Conventions, runnerContext.StartVersion, runnerContext.Version);
            }
            else
            {
                VersionLoader = new VersionLoader(this, _migrationAssemblies, Conventions);
            }
        }
        public void BlankProfileDoesntLoadProfiles()
        {
            var _runnerContextMock = new Mock<IRunnerContext>();
            var _runnerMock = new Mock<IMigrationRunner>();
            var _conventionsMock = new Mock<IMigrationConventions>();

            _runnerContextMock.SetupGet(x => x.Profile).Returns(string.Empty);
            _runnerMock.SetupGet(x => x.MigrationAssembly).Returns(typeof(MigrationRunnerTests).Assembly);

            var profileLoader = new ProfileLoader(_runnerContextMock.Object, _runnerMock.Object, _conventionsMock.Object);

            profileLoader.ApplyProfiles();

            profileLoader.Profiles.Count().ShouldBe(0);
        }
Beispiel #4
0
        public MigrationRunner(
            [NotNull] IAssemblyCollection assemblies, [NotNull] IRunnerContext runnerContext,
            [NotNull] IMigrationProcessor processor, [CanBeNull] IVersionTableMetaData versionTableMetaData,
            [CanBeNull] IMigrationRunnerConventions migrationRunnerConventions, [CanBeNull] IConventionSet conventionSet,
            [CanBeNull] IMigrationScopeManager migrationScopeHandler = null)
        {
            _migrationAssemblies = assemblies;
            _logger           = new AnnouncerFluentMigratorLogger(runnerContext.Announcer);
            _stopWatch        = runnerContext.StopWatch;
            _processorOptions = new ProcessorOptions(runnerContext);

            Processor     = processor;
            RunnerContext = runnerContext;

            var migrationRunnerConventionsAccessor = new AssemblySourceMigrationRunnerConventionsAccessor(
                serviceProvider: null,
                new AssemblySource(() => assemblies));

            Conventions = migrationRunnerConventions ?? migrationRunnerConventionsAccessor.MigrationRunnerConventions;

            var convSet = conventionSet ?? new DefaultConventionSet(runnerContext);

            _migrationScopeManager = migrationScopeHandler ?? new MigrationScopeHandler(Processor);
            _migrationValidator    = new MigrationValidator(_logger, convSet);
            MigrationLoader        = new DefaultMigrationInformationLoader(Conventions, _migrationAssemblies,
                                                                           runnerContext.Namespace,
                                                                           runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader     = new ProfileLoader(runnerContext, this, Conventions);
            MaintenanceLoader = new MaintenanceLoader(_migrationAssemblies, runnerContext.Tags, Conventions);

            if (runnerContext.NoConnection)
            {
                _versionLoader = new Lazy <IVersionLoader>(
                    () => new ConnectionlessVersionLoader(
                        this,
                        _migrationAssemblies,
                        convSet,
                        Conventions,
                        runnerContext,
                        versionTableMetaData));
            }
            else
            {
                _versionLoader = new Lazy <IVersionLoader>(
                    () => new VersionLoader(this, _migrationAssemblies, convSet, Conventions, runnerContext, versionTableMetaData));
            }
        }
        public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssembly = assembly;
            _announcer = runnerContext.Announcer;
            Processor = processor;
            _stopWatch = runnerContext.StopWatch;

            SilentlyFail = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;

            VersionLoader = new VersionLoader(this, _migrationAssembly, Conventions);
            MigrationLoader = new MigrationLoader(Conventions, _migrationAssembly, runnerContext.Namespace);
            ProfileLoader = new ProfileLoader(runnerContext, this, Conventions);
        }
        public MigrationRunner(ICollection<MigrationAssemblyInfo> assemblyInfos, IRunnerContext runnerContext, IMigrationProcessor processor, bool loadNestedNamespaces)
        {
            _migrationAssemblies = assemblyInfos;
            _announcer = runnerContext.Announcer;
            Processor = processor;
            _stopWatch = runnerContext.StopWatch;
            ApplicationContext = runnerContext.ApplicationContext;

            SilentlyFail = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;

            VersionLoader = new VersionLoader(this, assemblyInfos, Conventions);
            MigrationLoader = new MigrationLoader(Conventions, assemblyInfos, loadNestedNamespaces , runnerContext.Tags);
            ProfileLoader = new ProfileLoader(runnerContext, this, Conventions);
        }
Beispiel #7
0
        public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssembly = assembly;
            _announcer         = runnerContext.Announcer;
            Processor          = processor;
            _stopWatch         = runnerContext.StopWatch;

            SilentlyFail     = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
            {
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;
            }

            VersionLoader   = new VersionLoader(this, _migrationAssembly, Conventions);
            MigrationLoader = new MigrationLoader(Conventions, _migrationAssembly, runnerContext.Namespace);
            ProfileLoader   = new ProfileLoader(runnerContext, this, Conventions);
        }
        public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssembly = assembly;
            _announcer = runnerContext.Announcer;
            Processor = processor;
            _stopWatch = runnerContext.StopWatch;

            SilentlyFail = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();

            ProcessWorkingDirectory(runnerContext);

            ProcessAutoReverse(runnerContext);

            VersionLoader = new VersionLoader(this, _migrationAssembly, Conventions);
            MigrationLoader = new MigrationLoader(Conventions, _migrationAssembly, runnerContext.Namespace);
            ProfileLoader = new ProfileLoader(runnerContext, this, Conventions);
        }
        public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor)
        {
            _migrationAssembly = assembly;
            _announcer = runnerContext.Announcer;
            Processor = processor;
            _stopWatch = runnerContext.StopWatch;
            ApplicationContext = runnerContext.ApplicationContext;
            TransactionPerSession = runnerContext.TransactionPerSession;

            SilentlyFail = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;

            _migrationScopeHandler = new MigrationScopeHandler(Processor);
            _migrationValidator = new MigrationValidator(_announcer, Conventions);
            VersionLoader = new VersionLoader(this, _migrationAssembly, Conventions);
            MigrationLoader = new DefaultMigrationInformationLoader(Conventions, _migrationAssembly, runnerContext.Namespace, runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader = new ProfileLoader(runnerContext, this, Conventions);
        }
Beispiel #10
0
        public MigrationRunner(
            IAssemblyCollection assemblies, IRunnerContext runnerContext,
            IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData,
            IMigrationRunnerConventions migrationRunnerConventions, IConventionSet conventionSet)
        {
            _migrationAssemblies = assemblies;
            _announcer           = runnerContext.Announcer;
            Processor            = processor;
            _stopWatch           = runnerContext.StopWatch;
            RunnerContext        = runnerContext;

            SilentlyFail     = false;
            CaughtExceptions = null;

            Conventions = migrationRunnerConventions ?? GetMigrationRunnerConventions(runnerContext);

            var convSet = conventionSet ?? new DefaultConventionSet(runnerContext);

            _migrationScopeHandler = new MigrationScopeHandler(Processor);
            _migrationValidator    = new MigrationValidator(_announcer, convSet);
            MigrationLoader        = new DefaultMigrationInformationLoader(Conventions, _migrationAssemblies,
                                                                           runnerContext.Namespace,
                                                                           runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader     = new ProfileLoader(runnerContext, this, Conventions);
            MaintenanceLoader = new MaintenanceLoader(_migrationAssemblies, runnerContext.Tags, Conventions);

            if (runnerContext.NoConnection)
            {
                VersionLoader = new ConnectionlessVersionLoader(
                    this, _migrationAssemblies, convSet, Conventions,
                    runnerContext.StartVersion, runnerContext.Version, versionTableMetaData);
            }
            else
            {
                VersionLoader = new VersionLoader(this, _migrationAssemblies, convSet, Conventions, versionTableMetaData);
            }
        }
        public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData = null)
        {
            _migrationAssembly    = assembly;
            _announcer            = runnerContext.Announcer;
            Processor             = processor;
            _stopWatch            = runnerContext.StopWatch;
            ApplicationContext    = runnerContext.ApplicationContext;
            TransactionPerSession = runnerContext.TransactionPerSession;

            SilentlyFail     = false;
            CaughtExceptions = null;

            Conventions = new MigrationConventions();
            if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory))
            {
                Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory;
            }

            _migrationScopeHandler = new MigrationScopeHandler(Processor);
            _migrationValidator    = new MigrationValidator(_announcer, Conventions);
            VersionLoader          = new VersionLoader(this, _migrationAssembly, Conventions, versionTableMetaData);
            MigrationLoader        = new DefaultMigrationInformationLoader(Conventions, _migrationAssembly, runnerContext.Namespace, runnerContext.NestedNamespaces, runnerContext.Tags);
            ProfileLoader          = new ProfileLoader(runnerContext, this, Conventions);
        }
 public void ApplyProfiles()
 {
     ProfileLoader.ApplyProfiles();
 }