コード例 #1
0
        public async Task can_rollback_a_function_change()
        {
            await ResetSchema();

            await CreateSchemaObjectInDatabase(theHiloTable);

            var function = Function.ForSql(theFunctionBody);

            await CreateSchemaObjectInDatabase(function);

            var different = Function.ForSql(theEvenDifferentBody);

            var delta = await different.FindDelta(theConnection);

            var migration = new SchemaMigration(delta);

            await migration.ApplyAll(theConnection, new DdlRules(), AutoCreate.CreateOrUpdate);

            await migration.RollbackAll(theConnection, new DdlRules());

            // Should be back to the original function

            var lastDelta = await function.FindDelta(theConnection);

            lastDelta.Difference.ShouldBe(SchemaPatchDifference.None);
        }
コード例 #2
0
        private async Task AssertRollbackIsSuccessful(params Table[] otherTables)
        {
            await ResetSchema();

            foreach (var table in otherTables)
            {
                await CreateSchemaObjectInDatabase(table);
            }

            await CreateSchemaObjectInDatabase(initial);

            await Task.Delay(100.Milliseconds());

            var delta = await configured.FindDelta(theConnection);

            var migration = new SchemaMigration(new ISchemaObjectDelta[] { delta });

            await migration.ApplyAll(theConnection, new DdlRules(), AutoCreate.CreateOrUpdate);

            await Task.Delay(100.Milliseconds());

            await migration.RollbackAll(theConnection, new DdlRules());

            var delta2 = await initial.FindDelta(theConnection);

            delta2.Difference.ShouldBe(SchemaPatchDifference.None);
        }
コード例 #3
0
        public async Task rollback_a_function_creation()
        {
            await ResetSchema();

            await CreateSchemaObjectInDatabase(theHiloTable);

            var function = Function.ForSql(theFunctionBody);

            var delta = await function.FindDelta(theConnection);

            var migration = new SchemaMigration(delta);

            await migration.ApplyAll(theConnection, new DdlRules(), AutoCreate.CreateOrUpdate);

            (await theConnection.FunctionExists(function.Identifier)).ShouldBeTrue();

            await migration.RollbackAll(theConnection, new DdlRules());

            (await theConnection.FunctionExists(function.Identifier)).ShouldBeFalse();
        }
コード例 #4
0
        public async Task rollback_existing()
        {
            await ResetSchema();

            await CreateSchemaObjectInDatabase(theHiloTable);

            var function = Function.ForSql(theFunctionBody);

            await CreateSchemaObjectInDatabase(function);

            var toRemove = Function.ForRemoval(function.Identifier);

            var delta = await toRemove.FindDelta(theConnection);

            delta.Difference.ShouldBe(SchemaPatchDifference.Update);

            var migration = new SchemaMigration(delta);

            await migration.ApplyAll(theConnection, new DdlRules(), AutoCreate.CreateOrUpdate);

            await migration.RollbackAll(theConnection, new DdlRules());

            (await theConnection.FunctionExists(toRemove.Identifier)).ShouldBeTrue();
        }