private MigrationRunner GetRunner(Assembly assembly) { var factory = new SQLiteProcessorFactory(); var announcer = new NullAnnouncer(); var processor = factory.Create(connection, announcer, new MigrationOptions() { PreviewOnly = false, Timeout = 0 }); return(new MigrationRunner(assembly, new RunnerContext(announcer), processor)); }
public void Migrate() { var announcer = new TextWriterAnnouncer(Console.Out) { ShowElapsedTime = true, ShowSql = true }; IRunnerContext migrationContext = new RunnerContext(announcer); var factory = new SQLiteProcessorFactory(); IMigrationProcessor processor = factory.Create(_connectionString, announcer, new ProcessorOptions()); var runner = new MigrationRunner(typeof(Migrator).Assembly, migrationContext, processor); runner.MigrateUp(true); }
public void Migrate() { IAnnouncer announcer = new MigrationAnnouncer() { ShowSql = true }; IMigrationProcessorFactory migrationProcessorFactory = new SQLiteProcessorFactory(); ProcessorOptions options = new ProcessorOptions { PreviewOnly = false, // set to true to see the SQL Timeout = 60 }; using (IMigrationProcessor processor = migrationProcessorFactory.Create(_configuration.GetConnectionString("DefaultConnection"), announcer, options)) { MigrationRunner runner = new MigrationRunner(GetType().Assembly, new RunnerContext(announcer), processor); runner.MigrateUp(); } }
static void Main() { // Configure the DB connection var dbFileName = Path.Combine(AppContext.BaseDirectory, "test.db"); var csb = new SqliteConnectionStringBuilder { DataSource = dbFileName, Mode = SqliteOpenMode.ReadWriteCreate }; // Create the announcer to output the migration messages var announcer = new ConsoleAnnouncer() { ShowSql = true, }; // Processor specific options (usually none are needed) var options = new ProcessorOptions(); // Initialize the DB-specific processor var processorFactory = new SQLiteProcessorFactory(); var processor = processorFactory.Create(csb.ConnectionString, announcer, options); // Configure the runner var context = new RunnerContext(announcer) { AllowBreakingChange = true, }; // Create the migration runner var runner = new MigrationRunner( typeof(AddGTDTables).Assembly, context, processor); // Run the migrations runner.MigrateUp(); }
private static void RunInLegacyMode(string connectionString) { // Create the announcer to output the migration messages #pragma warning disable 612 var announcer = new ConsoleAnnouncer() { ShowSql = true, }; #pragma warning restore 612 // Processor specific options (usually none are needed) var options = new ProcessorOptions(); // Initialize the DB-specific processor #pragma warning disable 612 var processorFactory = new SQLiteProcessorFactory(serviceProvider: null); var processor = processorFactory.Create(connectionString, announcer, options); #pragma warning restore 612 // Configure the runner #pragma warning disable 612 var context = new RunnerContext(announcer) { AllowBreakingChange = true, }; #pragma warning restore 612 // Create the migration runner #pragma warning disable 612 var runner = new MigrationRunner( typeof(AddGTDTables).Assembly, context, processor); #pragma warning restore 612 // Run the migrations runner.MigrateUp(); }
public void Migrate(Action <IMigrationRunner> runnerAction) { var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 }; var factory = new SQLiteProcessorFactory(); var assembly = Assembly.GetAssembly(typeof(InitialMigration)); var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s)) { ShowSql = true }; var migrationContext = new RunnerContext(announcer); var processor = factory.Create(NHibernateConfigurationFactory.GetConnectionString(), announcer, options); var runner = new MigrationRunner(assembly, migrationContext, processor); runnerAction(runner); }