private SqlServerSchemaMigrator GenerateMigrations(SchemaMigrationContext context, params IMigrationExpression[] createTables)
        {
            ExecuteMigrations(createTables);

               var migrator = new SqlServerSchemaMigrator(new DebugAnnouncer());

               migrator.Generate(context);
               return migrator;
        }
        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 void ExecuteSchemaMigration()
        {
            BaseSchemaMigrator migrator;
            switch ( SchemaMigrationContext.FromDatabaseType)
            {
                case DatabaseType.SqlServer:
                case DatabaseType.SqlServer2008:
                case DatabaseType.SqlServer2005:
                    migrator = new SqlServerSchemaMigrator(new TextWriterAnnouncer(_announcerOutput));
                    break;
                case DatabaseType.Oracle:
                    migrator = new OracleSchemaMigrator(new TextWriterAnnouncer(_announcerOutput));
                    break;
                default:
                    throw new NotSupportedException(string.Format("Database type {0} not supported as source database",
                                                                  SchemaMigrationContext.FromDatabaseType));
            }

            migrator.Generate(SchemaMigrationContext);

            if ( _generateOnly )
                return;

            migrator.Migrate(SchemaMigrationContext);
        }
        /// <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);
        }