public void WillOnlyGenerateForeignKeyMigration() { // Act var create = new CreateTableExpression { TableName = "Foo" ,Columns = new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32, IsPrimaryKey = true } } }; var createBar = new CreateTableExpression { TableName = "FooBar" ,Columns = new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32 } } }; ExecuteMigrations(create, createBar, new CreateForeignKeyExpression { ForeignKey = new ForeignKeyDefinition { Name = "FK_Foo", ForeignTable = "FooBar", ForeignColumns = new[] { "Id" }, PrimaryTable = "Foo", PrimaryColumns = new[] { "Id" } } }); var context = GetDefaultContext(); context.Type = MigrationType.ForeignKeys; // Act var migrator = new SqlServerSchemaMigrator(new DebugAnnouncer()); migrator.Generate(context); // Assert context.MigrationIndex.ShouldBe(1); }
private SqlServerSchemaMigrator GenerateMigrations(SchemaMigrationContext context, params IMigrationExpression[] createTables) { ExecuteMigrations(createTables); var migrator = new SqlServerSchemaMigrator(new DebugAnnouncer()); migrator.Generate(context); return migrator; }
/// <summary> /// Migrates a set of tables using the provided context /// </summary> /// <param name="context">The migration context that controls how items are migrated between SQL Server and Oracle</param> /// <param name="createTables">The tables to be created in SQL Server and migrated to Oracle</param> private void MigrateTable(SchemaMigrationContext context, params CreateTableExpression[] createTables) { CreateTables(createTables); var migrator = new SqlServerSchemaMigrator(new DebugAnnouncer()); migrator.Generate(context); migrator.Migrate(context); AssertOracleTablesExist(createTables); }