internal FxVersionLoader(IMigrationRunner runner, IAssemblyCollection assemblies, IConventionSet conventionSet, IMigrationRunnerConventions conventions, IRunnerContext runnerContext, IVersionTableMetaData versionTableMetaData = null, string resource = "") { _conventionSet = conventionSet; _processor = runner.Processor; Runner = runner; Assemblies = assemblies; Conventions = conventions; VersionTableMetaData = versionTableMetaData ?? CreateVersionTableMetaData(runnerContext); VersionMigration = new VersionMigration(VersionTableMetaData); VersionSchemaMigration = new VersionSchemaMigration(VersionTableMetaData); VersionUniqueMigration = new VersionUniqueMigration(VersionTableMetaData); VersionDescriptionMigration = new VersionDescriptionMigration(VersionTableMetaData); VersionResourceMigration = new VersionResourceMigration(VersionTableMetaData); VersionTableMetaData.ApplicationContext = runnerContext.ApplicationContext; Resource = resource; LoadVersionInfo(); }
public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor) : this(new List<MigrationAssemblyInfo>() { new MigrationAssemblyInfo() { Assembly = assembly , Namespace = runnerContext.Namespace} }, runnerContext, processor, false) { }
public ConnectionlessProcessor(IMigrationGenerator generator, IRunnerContext context, IMigrationProcessorOptions options) { Generator = generator; Context = context; Announcer = Context.Announcer; Options = options; }
public TaskExecutor(IRunnerContext runnerContext) { if (runnerContext == null) throw new ArgumentNullException("runnerContext", "RunnerContext cannot be null"); RunnerContext = runnerContext; }
internal ConnectionlessVersionLoader( IMigrationRunner runner, IAssemblyCollection assemblies, IConventionSet conventionSet, IMigrationRunnerConventions conventions, IRunnerContext runnerContext, IVersionTableMetaData versionTableMetaData = null) { _migrationInformationLoader = runner.MigrationLoader; _processor = runner.Processor; Runner = runner; Assemblies = assemblies; Conventions = conventions; StartVersion = runnerContext.StartVersion; TargetVersion = runnerContext.Version; VersionInfo = new VersionInfo(); VersionTableMetaData = versionTableMetaData ?? (IVersionTableMetaData)Activator.CreateInstance(assemblies.Assemblies.GetVersionTableMetaDataType( Conventions, runnerContext)); VersionMigration = new VersionMigration(VersionTableMetaData); VersionSchemaMigration = new VersionSchemaMigration(VersionTableMetaData); VersionUniqueMigration = new VersionUniqueMigration(VersionTableMetaData); VersionDescriptionMigration = new VersionDescriptionMigration(VersionTableMetaData); if (VersionTableMetaData is DefaultVersionTableMetaData defaultMetaData) { conventionSet.SchemaConvention?.Apply(defaultMetaData); } LoadVersionInfo(); }
public AnnouncingHtmlOutputUrlProcessor( IValidatorWrapper validator, IRunnerContext context, IFileNameGenerator fileNameGenerator, ResourceCopier resourceCopier, IValidatorReportWriterFactory reportWriterFactory, IStreamFactory streamFactory, IHtmlIndexFileWriter htmlIndexFileWriter) { if (validator == null) throw new ArgumentNullException("validator"); if (context == null) throw new ArgumentNullException("context"); if (fileNameGenerator == null) throw new ArgumentNullException("fileNameGenerator"); if (resourceCopier == null) throw new ArgumentNullException("resourceCopier"); if (reportWriterFactory == null) throw new ArgumentNullException("reportWriterFactory"); if (streamFactory == null) throw new ArgumentNullException("streamFactory"); if (htmlIndexFileWriter == null) throw new ArgumentNullException("htmlIndexFileWriter"); this.mValidator = validator; this.mContext = context; this.mFileNameGenerator = fileNameGenerator; this.mResourceCopier = resourceCopier; this.mReportWriterFactory = reportWriterFactory; this.mStreamFactory = streamFactory; this.mHtmlIndexFileWriter = htmlIndexFileWriter; }
public MigrationRunner( [NotNull] IAssemblyCollection assemblies, [NotNull] IRunnerContext runnerContext, [NotNull] IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData = null, [CanBeNull] IMigrationRunnerConventions migrationRunnerConventions = null) : this(assemblies, runnerContext, processor, versionTableMetaData, migrationRunnerConventions, conventionSet : null, migrationScopeHandler : null) { }
public void SetUp() { _runnerContext = new RunnerContext(new TextWriterAnnouncer(System.Console.Out)) { Namespace = "FluentMigrator.Tests.Integration.Migrations" }; }
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); } }
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 ProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, IMigrationRunnerConventions conventions) { _runner = runner; _conventions = conventions; _serviceProvider = null; Profiles = FindProfilesIn(runner.MigrationAssemblies, runnerContext.Profile).ToList(); }
public MigrationRunner( IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData = null, IMigrationRunnerConventions migrationRunnerConventions = null) : this(assemblies, runnerContext, processor, versionTableMetaData, migrationRunnerConventions, conventionSet : null) { }
public ConnectionlessProcessorFactory( [NotNull] IGeneratorAccessor generatorAccessor, [NotNull] IRunnerContext runnerContext) { _generator = generatorAccessor.Generator; _databaseId = runnerContext.Database; Name = _generator.GetName(); }
public ProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, IMigrationRunnerConventions conventions) { Runner = runner; Assemblies = runner.MigrationAssemblies; Profile = runnerContext.Profile; Conventions = conventions; Initialize(); }
public TaskExecutor(IRunnerContext runnerContext) { if (runnerContext == null) { throw new ArgumentNullException("runnerContext", "RunnerContext cannot be null"); } RunnerContext = runnerContext; }
public ProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, IMigrationConventions conventions, bool isBeforeProfile) { Runner = runner; Assembly = runner.MigrationAssembly; Profile = isBeforeProfile ? runnerContext.BeforeProfile : runnerContext.Profile; Conventions = conventions; Initialize(); }
internal VersionLoader( [NotNull] IMigrationRunner runner, [NotNull] Assembly assembly, [NotNull] IConventionSet conventionSet, [NotNull] IMigrationRunnerConventions conventions, [NotNull] IRunnerContext runnerContext) : this(runner, new SingleAssembly(assembly), conventionSet, conventions, runnerContext) { }
public TaskExecutor(IRunnerContext runnerContext, AssemblyLoaderFactory assemblyLoaderFactory, MigrationProcessorFactoryProvider processorFactoryProvider) { if (runnerContext == null) throw new ArgumentNullException("runnerContext"); if (assemblyLoaderFactory == null) throw new ArgumentNullException("assemblyLoaderFactory"); RunnerContext = runnerContext; AssemblyLoaderFactory = assemblyLoaderFactory; ProcessorFactoryProvider = processorFactoryProvider; }
public ProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, IEnumerable<Assembly> assemblies, IMigrationConventions conventions) { Runner = runner; Assemblies = assemblies.ToList(); Profile = runnerContext.Profile; Conventions = conventions; Initialize(); }
public ProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, IMigrationConventions conventions) { Runner = runner; Assembly = runner.MigrationAssembly; Profile = runnerContext.Profile; Conventions = conventions; Initialize(); }
internal FxVersionLoader( IMigrationRunner runner, Assembly assembly, IConventionSet conventionSet, IMigrationRunnerConventions conventions, IRunnerContext runnerContext) : this(runner, new SingleAssembly(assembly), conventionSet, conventions, runnerContext) { }
public void SetValuesFrom(IRunnerContext runnerContext) { PreviewOnly = runnerContext.PreviewOnly; Timeout = runnerContext.Timeout == null ? null : (TimeSpan?)TimeSpan.FromSeconds(runnerContext.Timeout.Value); ProviderSwitches = runnerContext.ProviderSwitches; ConnectionString = runnerContext.Connection; }
public void SetUp() { _runnerContext = new RunnerContext(new TextWriterAnnouncer(System.Console.Out)) { Database = "sqlserver", Target = GetType().Assembly.Location, Connection = IntegrationTestOptions.SqlServer.ConnectionString, Namespace = "FluentMigrator.Tests.Integration.Migrations" }; }
public TaskExecutor( [NotNull] IRunnerContext runnerContext, [CanBeNull] IConnectionStringProvider connectionStringProvider, [NotNull] AssemblyLoaderFactory assemblyLoaderFactory, // ReSharper disable once UnusedParameter.Local MigrationProcessorFactoryProvider factoryProvider) : this( runnerContext, assemblyLoaderFactory, connectionStringProvider) { }
public ConnectionlessProcessor( IMigrationGenerator generator, IRunnerContext context, IMigrationProcessorOptions options) { _logger = new AnnouncerFluentMigratorLogger(context.Announcer); _legacyOptions = options; DatabaseType = context.Database; Generator = generator; Announcer = context.Announcer; Options = options.GetProcessorOptions(connectionString: null); }
private IMigrationRunnerConventions GetMigrationRunnerConventions(IRunnerContext runnerContext) { var matchedType = _migrationAssemblies .GetExportedTypes() .FirstOrDefault(t => typeof(IMigrationRunnerConventions).IsAssignableFrom(t)); if (matchedType != null) { return((IMigrationRunnerConventions)Activator.CreateInstance(matchedType)); } return(new MigrationRunnerConventions()); }
public void SetValuesFrom(IRunnerContext runnerContext) { Task = runnerContext.Task; Version = runnerContext.Version; StartVersion = runnerContext.StartVersion; Steps = runnerContext.Steps; Profile = runnerContext.Profile; Tags = runnerContext.Tags?.ToArray(); AllowBreakingChange = runnerContext.AllowBreakingChange; TransactionPerSession = runnerContext.TransactionPerSession; ApplicationContext = runnerContext.ApplicationContext; NoConnection = runnerContext.NoConnection; }
public TaskExecutor(IRunnerContext runnerContext, AssemblyLoaderFactory assemblyLoaderFactory, MigrationProcessorFactoryProvider processorFactoryProvider) { if (runnerContext == null) { throw new ArgumentNullException("runnerContext"); } if (assemblyLoaderFactory == null) { throw new ArgumentNullException("assemblyLoaderFactory"); } RunnerContext = runnerContext; AssemblyLoaderFactory = assemblyLoaderFactory; ProcessorFactoryProvider = processorFactoryProvider; }
private IMigrationConventions GetMigrationConventions(IRunnerContext runnerContext) { Type matchedType = this._migrationAssemblies.GetExportedTypes().FirstOrDefault(t => typeof(IMigrationConventions).IsAssignableFrom(t)); if (matchedType == null) { if (!string.IsNullOrEmpty(runnerContext.SchemaName)) { return(new MigrationConventionsWithDefaultSchema(runnerContext.SchemaName)); } return(new MigrationConventions()); } return((IMigrationConventions)Activator.CreateInstance(matchedType)); }
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 TaskExecutor([NotNull] IRunnerContext runnerContext) { var runnerCtxt = runnerContext ?? throw new ArgumentNullException(nameof(runnerContext)); _logger = new AnnouncerFluentMigratorLogger(runnerCtxt.Announcer); _runnerOptions = new RunnerOptions(runnerCtxt); var asmLoaderFactory = new AssemblyLoaderFactory(); _assemblySource = new AssemblySource(() => new AssemblyCollection(asmLoaderFactory.GetTargetAssemblies(runnerCtxt.Targets))); ConnectionStringProvider = new DefaultConnectionStringProvider(); _lazyServiceProvider = new Lazy <IServiceProvider>( () => runnerContext .CreateServices( ConnectionStringProvider, asmLoaderFactory) .BuildServiceProvider(validateScopes: true)); }
/// <summary> /// Loads the connection string using the connection string provider for the given assembly /// </summary> /// <param name="assemblies">The assembly to load the connection string from</param> /// <param name="connectionStringProvider">The connection string provider</param> /// <param name="runnerContext">The runner context</param> /// <returns>The found connection string</returns> public static string LoadConnectionString( this IReadOnlyCollection <Assembly> assemblies, IConnectionStringProvider connectionStringProvider, IRunnerContext runnerContext) { var singleAssembly = assemblies.Count == 1 ? assemblies.Single() : null; var singleAssemblyLocation = singleAssembly != null ? singleAssembly.Location : string.Empty; var connectionString = connectionStringProvider.GetConnectionString( runnerContext.Announcer, runnerContext.Connection, runnerContext.ConnectionStringConfigPath, singleAssemblyLocation, runnerContext.Database); return(connectionString); }
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); }
internal static IServiceCollection CreateServices( [NotNull] this IRunnerContext runnerContext, [CanBeNull] IConnectionStringProvider connectionStringProvider, [CanBeNull] AssemblyLoaderFactory defaultAssemblyLoaderFactory = null) { var services = new ServiceCollection(); var assemblyLoaderFactory = defaultAssemblyLoaderFactory ?? new AssemblyLoaderFactory(); if (!runnerContext.NoConnection && connectionStringProvider == null) { runnerContext.NoConnection = true; } // Configure the migration runner services .AddLogging(lb => lb.AddProvider(new LegacyFluentMigratorLoggerProvider(runnerContext.Announcer))) .AddFluentMigratorCore() .AddAllDatabases() .Configure <SelectingProcessorAccessorOptions>(opt => opt.ProcessorId = runnerContext.Database) .AddSingleton(assemblyLoaderFactory) .Configure <TypeFilterOptions>( opt => { opt.Namespace = runnerContext.Namespace; opt.NestedNamespaces = runnerContext.NestedNamespaces; }) .Configure <AssemblySourceOptions>(opt => opt.AssemblyNames = runnerContext.Targets) .Configure <RunnerOptions>( opt => { opt.SetValuesFrom(runnerContext); }) .Configure <ProcessorOptions>(opt => { opt.SetValuesFrom(runnerContext); }) .Configure <AppConfigConnectionStringAccessorOptions>( opt => opt.ConnectionStringConfigPath = runnerContext.ConnectionStringConfigPath); // Configure the processor if (runnerContext.NoConnection) { // Always return the connectionless processor services .AddScoped <IProcessorAccessor, ConnectionlessProcessorAccessor>(); } return(services); }
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); }
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 DefaultConventionSet(IRunnerContext runnerContext) { var schemaConvention = new DefaultSchemaConvention(new DefaultSchemaNameConvention(runnerContext?.DefaultSchemaName)); ColumnsConventions = new List <IColumnsConvention>() { new DefaultPrimaryKeyNameConvention(), }; ConstraintConventions = new List <IConstraintConvention>() { new DefaultConstraintNameConvention(), schemaConvention, }; ForeignKeyConventions = new List <IForeignKeyConvention>() { new DefaultForeignKeyNameConvention(), schemaConvention, }; IndexConventions = new List <IIndexConvention>() { new DefaultIndexNameConvention(), schemaConvention, }; SequenceConventions = new List <ISequenceConvention>() { schemaConvention, }; AutoNameConventions = new List <IAutoNameConvention>() { new DefaultAutoNameConvention(), }; SchemaConvention = schemaConvention; RootPathConvention = new DefaultRootPathConvention(runnerContext?.WorkingDirectory); }
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); }
/// <summary> /// Find the version table meta data in the given assembly collection /// </summary> /// <param name="assemblies">The assembly collection</param> /// <param name="runnerConventions">The runner conventions used to identify a version table metadata type</param> /// <param name="runnerContext">The runner context defining the search boundaries for the custom version table metadata type</param> /// <returns>A custom or the default version table metadata instance</returns> public static Type GetVersionTableMetaDataType( [CanBeNull] this IEnumerable <Assembly> assemblies, [NotNull] IMigrationRunnerConventions runnerConventions, [NotNull] IRunnerContext runnerContext) { if (assemblies == null) { return(typeof(DefaultVersionTableMetaData)); } var exportedTypes = assemblies.GetExportedTypes(); var matchedType = exportedTypes .FilterByNamespace(runnerContext.Namespace, runnerContext.NestedNamespaces) .FirstOrDefault(t => runnerConventions.TypeIsVersionTableMetaData(t)); if (matchedType == null) { return(typeof(DefaultVersionTableMetaData)); } return(matchedType); }
internal VersionLoader(IMigrationRunner runner, IAssemblyCollection assemblies, [NotNull] IConventionSet conventionSet, [NotNull] IMigrationRunnerConventions conventions, [NotNull] IRunnerContext runnerContext, [CanBeNull] IVersionTableMetaData versionTableMetaData = null) { _conventionSet = conventionSet; _processor = runner.Processor; Runner = runner; Assemblies = assemblies; Conventions = conventions; VersionTableMetaData = versionTableMetaData ?? CreateVersionTableMetaData(runnerContext); VersionMigration = new VersionMigration(VersionTableMetaData); VersionSchemaMigration = new VersionSchemaMigration(VersionTableMetaData); VersionUniqueMigration = new VersionUniqueMigration(VersionTableMetaData); VersionDescriptionMigration = new VersionDescriptionMigration(VersionTableMetaData); VersionTableMetaData.ApplicationContext = runnerContext.ApplicationContext; LoadVersionInfo(); }
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 void Execute(IRunnerContext runnerContext) { if (runnerContext == null) throw new ArgumentNullException("runnerContext", "RunnerContext cannot be null"); RunnerContext = runnerContext; Initialize(); switch (RunnerContext.Task) { case null: case "": case "migrate": case "migrate:up": if (RunnerContext.Version != 0) Runner.MigrateUp(RunnerContext.Version); else Runner.MigrateUp(); break; case "rollback": if (RunnerContext.Steps == 0) RunnerContext.Steps = 1; Runner.Rollback(RunnerContext.Steps); break; case "rollback:toversion": Runner.RollbackToVersion(RunnerContext.Version); break; case "rollback:all": Runner.RollbackToVersion(0); break; case "migrate:down": Runner.MigrateDown(RunnerContext.Version); break; } }
internal virtual IMigrationRunner GenerateRunner(IRunnerContext context, IMigrationProcessor processor) { return new MigrationRunner(_assembly, context, processor); }
/// <summary>Get a profile loader.</summary> /// <param name="runnerContext">The runner metadata.</param> /// <param name="runner">The runner which executes migrations.</param> /// <param name="conventions">The default rules for migration mappings.</param> public virtual IProfileLoader GetProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, IMigrationConventions conventions) { return new ProfileLoader(runnerContext, runner, conventions); }
public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor) : this(new[] { assembly }, runnerContext, processor) { }
private void ProcessAutoReverse(IRunnerContext runnerContext) { Conventions.GetAutoReverse = () => System.Convert.ToBoolean(runnerContext.AutoReverse); }
public FakeTaskExecutor(IRunnerContext runnerContext, IMigrationRunner runner) : base(runnerContext) { this.runner = runner; }
private void ProcessWorkingDirectory(IRunnerContext runnerContext) { if (!string.IsNullOrEmpty(runnerContext.WorkingDirectory)) Conventions.GetWorkingDirectory = () => runnerContext.WorkingDirectory; }
public ProfileLoader(IRunnerContext runnerContext, IMigrationRunner runner, Assembly assembly, IMigrationConventions conventions) : this(runnerContext, runner, new[] { assembly }, conventions) { }
public MockHtmlOutputUrlProcessor( IRunnerContext context, IValidatorWrapper validator, IValidatorReportWriterFactory reportWriterFactory, IFileNameGenerator fileNameGenerator, ResourceCopier resourceCopier, IStreamFactory streamFactory, IHtmlIndexFileWriter htmlIndexFileWriter) { this.mContext = context; this.mValidator = validator; this.mReportWriterFactory = reportWriterFactory; this.mFileNameGenerator = fileNameGenerator; this.mResourceCopier = resourceCopier; this.mStreamFactory = streamFactory; this.mHtmlIndexFileWriter = htmlIndexFileWriter; }
public MigrationRunner(Assembly assembly, IRunnerContext runnerContext, IMigrationProcessor processor) : this(new SingleAssembly(assembly), runnerContext, processor) { }
public TaskExecutor(IRunnerContext runnerContext) : this(runnerContext, new AssemblyLoaderFactory(), new MigrationProcessorFactoryProvider()) { }
private static MigrationRunner BuildMigrationRunner(Assembly migrationAssembly, IRunnerContext runnerContext, IMigrationProcessor processor) { var migrationRunner = new MigrationRunner(migrationAssembly, runnerContext, processor); return migrationRunner; }