本文整理汇总了C#中FluentMigrator.Runner.Announcers.TextWriterAnnouncer类的典型用法代码示例。如果您正苦于以下问题:C# TextWriterAnnouncer类的具体用法?C# TextWriterAnnouncer怎么用?C# TextWriterAnnouncer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextWriterAnnouncer类属于FluentMigrator.Runner.Announcers命名空间,在下文中一共展示了TextWriterAnnouncer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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;
}
}
示例3: 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);
}
}
示例4: StartMigration
public void StartMigration()
{
var consoleAnnouncer = new TextWriterAnnouncer(System.Console.Out)
{
ShowElapsedTime = true,
ShowSql = true
};
var runnerContext = new RunnerContext(consoleAnnouncer)
{
Database= DataBaseType,
Connection=connStr,
Target=assemblyPath,
PreviewOnly= false,
Namespace=string.Empty,
Task=string.Empty,
Version=0,
Steps=1,
WorkingDirectory = currentPath,
Profile=string.Empty,
Timeout=0,
ConnectionStringConfigPath=string.Empty
};
TaskExecutor tskMigration = new TaskExecutor(runnerContext);
tskMigration.Execute();
}
示例5: Rollback
public void Rollback(bool showSql = false)
{
using (var announcer = new TextWriterAnnouncer(Console.Out) { ShowSql = showSql })
{
var runner = CreateRunner(announcer);
runner.RollbackToVersion(0);
}
}
示例6: MigrateToLatest
public void MigrateToLatest(bool showSql = false)
{
using (var announcer = new TextWriterAnnouncer(Console.Out) { ShowSql = showSql })
{
var runner = CreateRunner(announcer);
runner.MigrateUp();
}
}
示例7: Migrator
public Migrator(DatabaseConfig databaseConfig)
{
_databaseConfig = databaseConfig;
NamespaceContainingMigrations = "Habanero.Test.Migrations";
AssemblyContainingMigrations = Assembly.GetExecutingAssembly();
MigrationProcessorFactory = GetMigrationProcessorFactory(databaseConfig);
Announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
_databaseInitialiser = new DatabaseInitialiser(databaseConfig);
}
示例8: SetUp
public void SetUp()
{
_stringWriter = new StringWriter();
_announcer = new TextWriterAnnouncer(_stringWriter)
{
ShowElapsedTime = true,
ShowSql = true
};
}
示例9: Migrate
public void Migrate(Action<IMigrationRunner> runnerAction)
{
var options = new MigrationOptions { PreviewOnly = false, Timeout = 0 };
var factory = new FluentMigrator.Runner.Processors.MigrationProcessorFactoryProvider().GetFactory(_dbType);
var announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
var migrationContext = new RunnerContext(announcer);
var processor = factory.Create(_connectionString, announcer, options);
var runner = new MigrationRunner(_migrationAssembly, migrationContext, processor);
runnerAction(runner);
}
示例10: Migrate
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);
}
示例11: MakeTask
private static TaskExecutor MakeTask(string task)
{
var announcer = new TextWriterAnnouncer(System.Console.Out);
var runnerContext = new RunnerContext(announcer)
{
Database = "Firebird",
Connection = IntegrationTestOptions.Firebird.ConnectionString,
Targets = new[] { Assembly.GetExecutingAssembly().Location },
Namespace = "FluentMigrator.Tests.Integration.Migrations.Firebird.FirstVersion",
Task = task,
};
return new TaskExecutor(runnerContext);
}
示例12: MakeTask
protected TaskExecutor MakeTask(string task, string migrationsNamespace)
{
var announcer = new TextWriterAnnouncer(System.Console.Out);
var runnerContext = new RunnerContext(announcer)
{
Database = "Firebird",
Connection = IntegrationTestOptions.Firebird.ConnectionString,
Targets = new[] { Assembly.GetExecutingAssembly().Location },
Namespace = migrationsNamespace,
Task = task
};
return new TaskExecutor(runnerContext);
}
示例13: InitializeProcessor
IMigrationProcessor InitializeProcessor()
{
dynamic options = _configuration.MigrationEngineOptions;
writer = new StringWriter();
var announcer = new TextWriterAnnouncer(writer);
var processorFactory = ProcessorFactory.GetFactory(options.DatabaseType);
var processor = processorFactory.Create(_configuration.ConnectionString,announcer, new ProcessorOptions
{
PreviewOnly = false,
Timeout = options.Timeout
});
return processor;
}
示例14: 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();
}
示例15: 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);
}
}