protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var announcer = new NullAnnouncer();
            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "Server.Migrations"
            };

            var options = new MigrationOptions();
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(
                ConfigurationManager.ConnectionStrings["Simple.Data.Properties.Settings.DefaultConnectionString"].ConnectionString,
                announcer,
                options);
            var runner = new MigrationRunner(assembly, migrationContext, processor);
            runner.MigrateUp(true);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "CPNRealm"));

            JsonSettings.RetainCasing = true;

            StaticConfiguration.DisableErrorTraces = false;
        }
Beispiel #2
0
        private MigrationRunner CreateMigrationRunner()
        {
            var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var type      = typeof(TMigrations);
            var assembly  = Assembly.GetAssembly(type);

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = type.Namespace
            };

            if (!DatabaseExists())
            {
                HandleMissingDatabase();
            }
            else
            {
                //CheckForAndRemoveOldVersionInfoKey();
            }

            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 10000
            };
            var factory          = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var connectionString = DatabaseConfig.GetConnectionString();
            var processor        = factory.Create(connectionString, announcer, options);
            var runner           = new MigrationRunner(assembly, migrationContext, processor);

            return(runner);
        }
        public static void MigrateDown(string connectionString, long?migrationId)
        {
            var announcer = GetAnnouncer();
            var assembly  = Assembly.GetAssembly(typeof(Seed));

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = typeof(Seed).Namespace
            };

            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 60
            };
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();

            using (var processor = factory.Create(connectionString, announcer, options))
            {
                var runner = new MigrationRunner(assembly, migrationContext, processor);
                if (migrationId.HasValue)
                {
                    runner.RollbackToVersion(migrationId.Value);
                }
                else
                {
                    runner.Rollback(int.MaxValue);
                }
            }
        }
Beispiel #4
0
        public UpdateDatabase(String ConnectionString)
        {
            var announcer = new TextWriterAnnouncer(s => System.Console.WriteLine(s));
            var assembly  = Assembly.GetAssembly(typeof(SchemaChanges.frm_20170221_1442));

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "TimeGo.DataModel.SchemaChanges"
            };

            IMigrationProcessorOptions options = new ProcessorOptions {
                PreviewOnly = false,
                Timeout     = 60
            };



            var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(ConnectionString, announcer, options);


            var runner = new MigrationRunner(assembly, migrationContext, processor);

            runner.MigrateUp();
        }
Beispiel #5
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var announcer = new NullAnnouncer();
            var assembly  = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "Server.Migrations"
            };

            var options   = new MigrationOptions();
            var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(
                ConfigurationManager.ConnectionStrings["Simple.Data.Properties.Settings.DefaultConnectionString"].ConnectionString,
                announcer,
                options);
            var runner = new MigrationRunner(assembly, migrationContext, processor);

            runner.MigrateUp(true);

            pipelines.EnableBasicAuthentication(new BasicAuthenticationConfiguration(new UserValidator(), "CPNRealm"));

            JsonSettings.RetainCasing = true;

            StaticConfiguration.DisableErrorTraces = false;
        }
Beispiel #6
0
 public void Migrate(Action<IMigrationRunner> runnerAction)
 {
     var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 };
     var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
     var assembly = Assembly.GetExecutingAssembly();
     var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
     var migrationContext = new RunnerContext(announcer);
     var processor = factory.Create(this._connectionString, announcer, options);
     var runner = new MigrationRunner(assembly, migrationContext, processor);
     runnerAction(runner);
 }
Beispiel #7
0
 private MigrationRunner GetMigrationRunner(long version, string profile = "")
 {
     if(string.IsNullOrEmpty(ConnectionString))
         throw new EmptyConnectionStringException("ConnectionString property not initialized");
     var options = new MigrationOptions() {PreviewOnly = false, Timeout = 60};
     var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
     var processor = factory.Create(ConnectionString, Announcer, options);
     var assembly = Assembly.GetExecutingAssembly();
     var runner = new MigrationRunner(assembly, GetMigrationContext(version, profile), processor);
     return runner;
 }
        public static void MigrateToLatest()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            var migrationAssembly=  Assembly.GetExecutingAssembly();
            var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var migrationContext = new RunnerContext(announcer);
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 };
            var processor = factory.Create(connectionString, announcer, options);

            var runner = new MigrationRunner(migrationAssembly, migrationContext, processor);
            runner.MigrateUp();
        }
        private MigrationRunner GetMigrator()
        {
            var announcer = new TextWriterAnnouncer(s => logMethod.Invoke(s));

            var migrationContext = new RunnerContext(announcer);
            var options          = new MigrationOptions {
                PreviewOnly = false, Timeout = 60
            };
            var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(this.connectionString, announcer, options);
            var runner    = new MigrationRunner(migrationsAssembly, migrationContext, processor);

            return(runner);
        }
Beispiel #10
0
        public void Migrate(Action <IMigrationRunner> runnerAction)
        {
            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 0
            };
            var factory          = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var assembly         = Assembly.GetExecutingAssembly();
            var announcer        = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var migrationContext = new RunnerContext(announcer);
            var processor        = factory.Create(this._connectionString, announcer, options);
            var runner           = new MigrationRunner(assembly, migrationContext, processor);

            runnerAction(runner);
        }
Beispiel #11
0
        public void MigrateToLatest()
        {
            var announcer        = new NullAnnouncer();
            var assembly         = Assembly.GetExecutingAssembly();
            var migrationContext = new RunnerContext(announcer);
            var options          = new ProcessorOptions {
                PreviewOnly = false, Timeout = 60
            };
            var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(_settings.ConnectionString, announcer, options);
            var runner    = new MigrationRunner(assembly, migrationContext, processor);

            runner.MigrateUp(true);
        }
        public static void MigrateToLatest()
        {
            var connectionString  = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            var migrationAssembly = Assembly.GetExecutingAssembly();
            var announcer         = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var migrationContext  = new RunnerContext(announcer);
            var factory           = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var options           = new MigrationOptions {
                PreviewOnly = false, Timeout = 0
            };
            var processor = factory.Create(connectionString, announcer, options);

            var runner = new MigrationRunner(migrationAssembly, migrationContext, processor);

            runner.MigrateUp();
        }
Beispiel #13
0
        private MigrationRunner GetMigrationRunner(long version, string profile = "")
        {
            if (string.IsNullOrEmpty(ConnectionString))
            {
                throw new EmptyConnectionStringException("ConnectionString property not initialized");
            }
            var options = new MigrationOptions()
            {
                PreviewOnly = false, Timeout = 60
            };
            var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var processor = factory.Create(ConnectionString, Announcer, options);
            var assembly  = Assembly.GetExecutingAssembly();
            var runner    = new MigrationRunner(assembly, GetMigrationContext(version, profile), processor);

            return(runner);
        }
Beispiel #14
0
    public static void MigrateToLatest(string connectionString)
    {
        // var announcer = new NullAnnouncer();
        var announcer        = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
        var assembly         = Assembly.GetExecutingAssembly();
        var migrationContext = new RunnerContext(announcer)
        {
            Namespace = "MyApp.Sql.Migrations"
        };
        var options = new MigrationOptions {
            PreviewOnly = false, Timeout = 60
        };
        var factory   = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
        var processor = factory.Create(connectionString, announcer, options);
        var runner    = new MigrationRunner(assembly, migrationContext, processor);

        runner.MigrateUp(true);
    }
Beispiel #15
0
        public static void MigrateToLatestVersion(string connectionString)
        {
            var announcer = GetAnnouncer();
            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = typeof(Runner).Namespace
            };

            var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            using (var processor = factory.Create(connectionString, announcer, options))
            {
                var runner = new MigrationRunner(assembly, migrationContext, processor);
                runner.MigrateUp(true);
            }
        }
Beispiel #16
0
        public void Migrate(Action<MigrationRunner> runnerAction)
        {
            var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 };
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var assembly = Assembly.GetExecutingAssembly();

            //using (var announcer = new NullAnnouncer())
            var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var migrationContext = new RunnerContext(announcer)
            {
            #if DEBUG
                // will create testdata
                Profile = "development"
            #endif
            };
            var processor = factory.Create(this.connectionString, announcer, options);
            var runner = new MigrationRunner(assembly, migrationContext, processor);
            runnerAction(runner);
        }
Beispiel #17
0
        public static void MigrateToLatest(string connectionString)
        {
            // var announcer = new NullAnnouncer();
            var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "DexMigrator.Migrations"

            };
            System.Console.WriteLine("This does stuff -----------------------------------------------------");
            var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
            var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            using (var processor = factory.Create(connectionString, announcer, options))
            {
                var runner = new MigrationRunner(assembly, migrationContext, processor);
                runner.MigrateUp(true);
            }
        }
        public void Migrate(Action <IMigrationRunner> runnerAction)
        {
            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 0
            };
            var factory  = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
            var assembly = Assembly.GetExecutingAssembly();

            //using (var announcer = new NullAnnouncer())
            var announcer        = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var migrationContext = new RunnerContext(announcer)
            {
#if DEBUG
                // will create testdata
                Profile = "development"
#endif
            };
            var processor = factory.Create(this.connectionString, announcer, options);
            var runner    = new MigrationRunner(assembly, migrationContext, processor);

            runnerAction(runner);
        }
        public static void MigrateToLatest()
        {
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ElementContext"].ConnectionString;

            var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            var assembly  = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = "BaseOfComponentWinform.Migrations"
            };

            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 60
            };
            var factory =
                new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();

            using (var processor = factory.Create(connectionString, announcer, options))
            {
                var runner = new MigrationRunner(assembly, migrationContext, processor);
                runner.MigrateUp(true);
            }
        }
        /// <summary>
        /// Runs database migrations of the specified module descriptor.
        /// </summary>
        /// <param name="moduleDescriptor">The module descriptor.</param>        
        /// <param name="up">if set to <c>true</c> migrates up; otherwise migrates down.</param>
        public void Migrate(ModuleDescriptor moduleDescriptor, bool up = true)
        {
            var announcer = new TextWriterAnnouncer(
                s =>
                    {
                        if (!string.IsNullOrWhiteSpace(s))
                        {
                            Log.Info(string.Concat("Migration on ", moduleDescriptor.Name, ". ", s));
                        }
                    });

            var assembly = moduleDescriptor.GetType().Assembly;

            var migrationTypes = assemblyLoader.GetLoadableTypes(assembly, typeof(Migration));

            if (!migrationTypes.Any())
            {
                Log.Info(string.Concat("Migration on ", moduleDescriptor.Name, ". No migrations found."));
                return;
            }

            var migrationContext = new RunnerContext(announcer)
            {
                Namespace = migrationTypes.First().Namespace
            };

            IMigrationProcessorOptions options = new ProcessorOptions
                {
                    PreviewOnly = false,
                    Timeout = (int)migrationTimeout.TotalSeconds
                };

            IMigrationProcessor processor;

            var connectionString = ConfigurationManager.ConnectionStrings["BetterCms"].ConnectionString;

            if (databaseType == DatabaseType.SqlAzure || databaseType == DatabaseType.SqlServer)
            {
                var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
                processor = factory.Create(connectionString, announcer, options);
            }
            else if (databaseType == DatabaseType.PostgreSQL)
            {
                var factory = new FluentMigrator.Runner.Processors.Postgres.PostgresProcessorFactory();
                processor = factory.Create(connectionString, announcer, options);
            }
            else if (databaseType == DatabaseType.Oracle)
            {
                var factory = new FluentMigrator.Runner.Processors.Oracle.OracleProcessorFactory();
                processor = factory.Create(connectionString, announcer, options);
            }
            else
            {
                throw new NotSupportedException(string.Format("Database type {0} is not supported for data migrations.", databaseType));
            }

            var runner = new MigrationRunner(assembly, migrationContext, processor);
            if (up)
            {
                runner.MigrateUp();
            }
            else
            {
                runner.MigrateDown(0);
            }
        }