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; }
public void CanMigrateASpecificVersionDown() { ExecuteWithSupportedProcessors(processor => { var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, "FluentMigrator.Tests.Integration.Migrations"); runner.MigrateUp(1); runner.VersionInfo.HasAppliedMigration(1).ShouldBeTrue(); processor.TableExists("Users").ShouldBeTrue(); runner.MigrateDown(1); runner.VersionInfo.HasAppliedMigration(1).ShouldBeFalse(); processor.TableExists("Users").ShouldBeFalse(); }); }
public void CanMigrateASpecificVersion() { ExecuteWithSupportedProcessors(processor => { var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, "FluentMigrator.Tests.Integration.Migrations", new TextWriterAnnouncer(System.Console.Out), string.Empty); runner.MigrateUp(1); runner.VersionInfo.HasAppliedMigration(1).ShouldBeTrue(); processor.TableExists("Users").ShouldBeTrue(); runner.Rollback(1); runner.VersionInfo.HasAppliedMigration(1).ShouldBeFalse(); processor.TableExists("Users").ShouldBeFalse(); }); }
private void runMigrationsInNamespace(IMigrationProcessor processor, string @namespace) { var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, @namespace); runner.MigrateUp(); }
public void SqlServerMigrationsAreTransactional() { var connection = new SqlConnection(sqlServerConnectionString); connection.Open(); var processor = new SqlServerProcessor(connection, new SqlServerGenerator()); var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, typeof(InvalidMigration).Namespace); try { runner.MigrateUp(); } catch { } processor.TableExists("Users").ShouldBeFalse(); }
public void CanRunMigrations() { ExecuteWithSupportedProcessors(processor => { var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, typeof(TestMigration).Namespace); runner.MigrateUp(); runner.VersionInfo.HasAppliedMigration(1).ShouldBeTrue(); runner.VersionInfo.HasAppliedMigration(2).ShouldBeTrue(); runner.VersionInfo.Latest().ShouldBe(2); runner.Rollback(2); runner.VersionInfo.HasAppliedMigration(1).ShouldBeFalse(); runner.VersionInfo.HasAppliedMigration(2).ShouldBeFalse(); runner.VersionInfo.Latest().ShouldBe(0); runner.RemoveVersionTable(); }); }
private void runMigrationsInNamespace(IMigrationProcessor processor, string @namespace) { var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, @namespace, new TextWriterAnnouncer(System.Console.Out)); runner.MigrateUp(); }
public void SqlServerMigrationsAreTransactional() { var connection = new SqlConnection(IntegrationTestOptions.SqlServer.ConnectionString); connection.Open(); var processor = new SqlServerProcessor(connection, new SqlServer2000Generator(), new TextWriterAnnouncer(System.Console.Out), new ProcessorOptions()); var runner = new MigrationVersionRunner(_conventions, processor, new MigrationLoader(_conventions), typeof(MigrationVersionRunnerTests).Assembly, typeof(InvalidMigration).Namespace, new TextWriterAnnouncer(System.Console.Out)); try { runner.MigrateUp(); } catch { } processor.TableExists("Users").ShouldBeFalse(); }
/// <summary>Executes sql create database scripts.</summary> public void Install() { IMigrationProcessorFactory processorFactory = ProcessorFactory.GetFactory("SqlServer"); IMigrationProcessor processor = processorFactory.Create(GetConnectionString()); MigrationVersionRunner runner = new MigrationVersionRunner( new MigrationConventions(), processor, new MigrationLoader(new MigrationConventions()), typeof(AddTables).Assembly, "Zeus.Installation.Migrations"); runner.MigrateUp(); }