本文整理汇总了C#中FluentMigrator.Runner.MigrationRunner.MigrateUp方法的典型用法代码示例。如果您正苦于以下问题:C# MigrationRunner.MigrateUp方法的具体用法?C# MigrationRunner.MigrateUp怎么用?C# MigrationRunner.MigrateUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluentMigrator.Runner.MigrationRunner
的用法示例。
在下文中一共展示了MigrationRunner.MigrateUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Migrate
public void Migrate(string connectionString, MigrationContext migrationContext)
{
var sw = Stopwatch.StartNew();
_announcer.Heading("Migrating " + connectionString);
var assembly = Assembly.GetExecutingAssembly();
var runnerContext = new RunnerContext(_announcer)
{
Namespace = "NzbDrone.Core.Datastore.Migration",
ApplicationContext = migrationContext
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new NzbDroneSqliteProcessorFactory();
var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, runnerContext, processor);
if (migrationContext.DesiredVersion.HasValue)
{
runner.MigrateUp(migrationContext.DesiredVersion.Value, true);
}
else
{
runner.MigrateUp(true);
}
sw.Stop();
_announcer.ElapsedTime(sw.Elapsed);
}
示例2: UpgradeDatabase
public void UpgradeDatabase()
{
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
var announcer = new TextWriterAnnouncer(s => Log.Debug(s));
var context = new RunnerContext(announcer)
{
Namespace = "Causal.Server.Migrations"
};
var providerName = ConfigurationManager.ConnectionStrings["CausalContext"].ProviderName;
MigrationProcessorFactory factory;
if (providerName.Equals("Npgsql", StringComparison.InvariantCultureIgnoreCase))
{
factory = new FluentMigrator.Runner.Processors.Postgres.PostgresProcessorFactory();
}
else if (providerName.Equals("System.Data.SqlClient", StringComparison.InvariantCultureIgnoreCase))
{
factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2008ProcessorFactory();
}
else
{
throw new Exception("Unknown provider for connection string CausalContext");
}
var options = new ProcessorOptions { PreviewOnly = false };
var processor = factory.Create(ConfigurationManager.ConnectionStrings["CausalContext"].ConnectionString, announcer, options);
var migrator = new MigrationRunner(assembly, context, processor);
migrator.MigrateUp(true);
}
示例3: Run
public static void Run(string connectionString)
{
var firstMigration = typeof(Lucid.Database.Migrations.Y2016.M01.V01);
var assembly = new SingleAssembly(firstMigration.Assembly);
var migrationGenerator = new SqlServer2008Generator();
var announcer = new NullAnnouncer();
var options = new ProcessorOptions();
var dbFactory = new SqlServerDbFactory();
var runnerContext = new RunnerContext(announcer)
{
Database = "SqlServer2008",
Connection = connectionString,
Targets = new string[] { firstMigration.Assembly.FullName },
NestedNamespaces = true,
Namespace = "Lucid.Database.Migrations",
};
using (var connection = new SqlConnection(connectionString))
using (var processor = new SqlServerProcessor(connection, migrationGenerator, announcer, options, dbFactory))
{
var runner = new MigrationRunner(assembly, runnerContext, processor);
runner.MigrateUp();
}
}
示例4: ApplicationStartup
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;
}
示例5: MigrateToLatest
public void MigrateToLatest(string connectionString, MigrationType migrationType)
{
lock (MigrationCache)
{
if (MigrationCache.Contains(connectionString.ToLower())) return;
_announcer.Heading("Migrating " + connectionString);
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(_announcer)
{
Namespace = "NzbDrone.Core.Datastore.Migration",
ApplicationContext = new MigrationContext
{
MigrationType = migrationType,
SQLiteAlter = _sqLiteAlter,
MigrationHelper = _migrationHelper,
}
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new SqliteProcessorFactory();
var processor = factory.Create(connectionString, _announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
MigrationCache.Add(connectionString.ToLower());
}
}
示例6: Run
public static void Run(IContainer settingsContainer)
{
var connectionString = settingsContainer.GetInstance<string>("DefaultConnection");
Announcer announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
announcer.ShowSql = true;
Assembly assembly = typeof(CreateTableEstacionamento).Assembly;
IRunnerContext migrationContext = new RunnerContext(announcer);
var options = new ProcessorOptions
{
PreviewOnly = false, // set to true to see the SQL
Timeout = 60
};
try
{
var factory = settingsContainer.GetInstance<MigrationProcessorFactory>(); //new FluentMigrator.Runner.Processors.SQLite.SQLiteProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
}
catch (Exception ex)
{
throw new InvalidOperationException("connectionString: " + connectionString, ex);
}
}
示例7: RunMigrations
public static void RunMigrations(string connectionString, string migration)
{
// var announcer = new NullAnnouncer();
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Azimuth.Migrations",
WorkingDirectory = "Migrations"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
switch (migration)
{
case "Run migrations":
runner.MigrateUp(true);
break;
case "Drop all tables":
runner.RollbackToVersion(201408091845);
runner.Rollback(1);
break;
}
}
示例8: MigrateTo
private void MigrateTo(long targetVersion)
{
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var announcer = new NullAnnouncer();
var processor = new SqlServer2012ProcessorFactory().Create(connectionString, announcer, options);
var migrationContext = new RunnerContext(announcer) { Namespace = "DDDEastAnglia.DatabaseMigrations.Migrations" };
var runner = new MigrationRunner(GetType().Assembly, migrationContext, processor);
runner.MigrateUp(targetVersion, true);
}
示例9: Update
public static void Update(IAnnouncer announcer, MigrationProcessorType type, string connectionString, Assembly migrationAssembly)
{
var context = new RunnerContext(announcer);
var options = new ProcessorOptions();
var factory = GetProcessorFactory(type);
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(migrationAssembly, context, processor);
runner.MigrateUp();
}
示例10: Migrate
public void Migrate()
{
var processor = GetProcessor();
var context = new RunnerContext(new NullAnnouncer());
var migrationRunner = new MigrationRunner(
typeof (SqlSchemaMigrator).Assembly,
context,
processor);
migrationRunner.MigrateUp();
}
示例11: MigrateToLatest
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();
}
示例12: MigrateToLatest
public void MigrateToLatest()
{
var announcer = new TextWriterAnnouncer(s => Debug.WriteLine(s));
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer);
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
using (var processor = factory.Create(connectionString, announcer, options))
{
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
}
}
示例13: MigrateToLatest
public void MigrateToLatest()
{
var asm = Assembly.GetExecutingAssembly();
var announcer = new TextWriterAnnouncer((str) =>
{
Debug.WriteLine(str);
});
var context = new RunnerContext(announcer);
var options = new MigrationOptions();
var factory = new SqlServer2012ProcessorFactory();
var processor = factory.Create(this._connectionString, announcer, options);
var runner = new MigrationRunner(asm, context, processor);
runner.MigrateUp(true);
}
示例14: MigrateToLatest
public static void MigrateToLatest(string connectionString)
{
var announcer = new NullAnnouncer();
var assembly = Assembly.GetExecutingAssembly();
var migrationContext = new RunnerContext(announcer)
{
Namespace = "Hinata.Data.Migrations"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
}
示例15: MigrateToLatest
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 = "Zoo.Models.Migrations"
};
var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
var factory = new FluentMigrator.Runner.Processors.SqlServer.SqlServer2012ProcessorFactory();
var processor = factory.Create(connectionString, announcer, options);
var runner = new MigrationRunner(assembly, migrationContext, processor);
runner.MigrateUp(true);
}