Example #1
0
        private IMigrationVersionRunner CreateRunner(IAnnouncer announcer)
        {
            var migrationConventions = new MigrationConventions();
            var processor = ProcessorFactory.GetFactory(_databaseProvider)
                .Create(_connectionString, announcer, new ProcessorOptions { PreviewOnly = false });

            return new MigrationVersionRunner(new MigrationConventions(),
                                                    processor,
                                                    new MigrationLoader(migrationConventions),
                                                    typeof(M001InitialVersion).Assembly,
                                                    null,
                                                    announcer,
                                                    null);
        }
Example #2
0
        private void EnsureMigration()
        {
            var connection = new System.Data.SqlClient.SqlConnection(connectionString);
            connection.Open();
            var processor = new SqlServerProcessor(connection, new SqlServer2000Generator(),
                new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions());
            var conventions = new MigrationConventions();
            var versionRunner = new FluentMigrator.Runner.MigrationVersionRunner(conventions, processor,
                new MigrationLoader(conventions), new NullAnnouncer());
            //var runner = new MigrationRunner(conventions, processor, new TextWriterAnnouncer(System.Console.Out), new StopWatch());
            //runner.Up(new TestCreateAndDropTableMigration());
            versionRunner.MigrateUp();

            versionRunner = null;
            connection = null;
        }
Example #3
0
        public void RunMigration()
        {
            if (!File.Exists(DbFile))
                System.Data.SQLite.SQLiteConnection.CreateFile(DbFile);

            //run migration
            using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
            {
                var conventions = new MigrationConventions();
                connection.Open();
                var processor = new FluentMigrator.Runner.Processors.Sqlite.SqliteProcessor(connection, new SqliteGenerator());
                var runner = new MigrationVersionRunner(conventions, processor, new MigrationLoader(conventions), typeof(SparkExampleWeb.Models.User));

                //upgrade to latest
                runner.UpgradeToLatest(false);
            }
        }
Example #4
0
        static void MigrateDatabase()
        {
            //make sure the sqlite db file exists
            if (!File.Exists(DbFile))
                System.Data.SQLite.SQLiteConnection.CreateFile(DbFile);

            //run migration
            using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
            {
                var conventions = new MigrationConventions();
                connection.Open();
                var processor = new FluentMigrator.Runner.Processors.Sqlite.SqliteProcessor(connection, new SqliteGenerator());
                var runner = new MigrationVersionRunner(conventions, processor, new MigrationLoader(conventions));

                //upgrade to latest
                runner.UpgradeToLatest(false);
            }
        }