Exemple #1
0
        public Migrator(string connectionString, params Assembly[] assemblies)
        {
            var announcer = new TextWriterAnnouncer(Console.Write);

            IAssemblyCollection assemblyCollection = new AssemblyCollection(assemblies);

            var migrationContext = new RunnerContext(announcer);

            var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
            PostgresProcessorFactory factory = new PostgresProcessorFactory();

            IMigrationProcessor processor = factory.Create(connectionString, announcer, options);
            runner = new MigrationRunner(assemblyCollection, migrationContext, processor);
        }
        protected virtual void Initialize()
        {
            List<Assembly> assemblies = new List<Assembly>();

            foreach (var target in RunnerContext.Targets)
            {
                var assembly = AssemblyLoaderFactory.GetAssemblyLoader(target).Load();

                if (!assemblies.Contains(assembly))
                {
                    assemblies.Add(assembly);
                }
            }

            var assemblyCollection = new AssemblyCollection(assemblies);

            var processor = RunnerContext.NoConnection? InitializeConnectionlessProcessor():InitializeProcessor(assemblyCollection);

            Runner = new MigrationRunner(assemblyCollection, RunnerContext, processor);
        }