public void Should_remove_old_property_after_phase_three()
    {
        var dialect = BuildSqlDialect.MySql;

        using (var connection = MySqlConnectionBuilder.Build())
        {
            connection.Open();

            //HACK: Thread Sleeps required since information_schema.statistics takes some time to update

            var sagaPhase1 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase1Saga), dialect);
            connection.ExecuteCommand(SagaScriptBuilder.BuildDropScript(sagaPhase1, dialect), "");
            Thread.Sleep(200);
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase1, dialect), "");
            Thread.Sleep(200);
            var phase1Schema = GetSchema(connection);
            CollectionAssert.Contains(phase1Schema, "Correlation_OrderNumber");
            CollectionAssert.DoesNotContain(phase1Schema, "Correlation_OrderId");

            var sagaPhase2 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase2Saga), dialect);
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase2, dialect), "");
            Thread.Sleep(200);
            var phase2Schema = GetSchema(connection);
            CollectionAssert.Contains(phase2Schema, "Correlation_OrderNumber");
            CollectionAssert.Contains(phase2Schema, "Correlation_OrderId");

            var sagaPhase3 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase3Saga), dialect);
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase3, dialect), "");
            Thread.Sleep(200);
            var phase3Schema = GetSchema(connection);
            CollectionAssert.DoesNotContain(phase3Schema, "Correlation_OrderNumber");
            CollectionAssert.Contains(phase3Schema, "Correlation_OrderId");
        }
    }
    public async Task Should_remove_old_property_after_phase_three()
    {
        var dialect    = BuildSqlDialect.MsSqlServer;
        var sagaPhase1 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase1Saga), dialect);
        var sagaPhase2 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase2Saga), dialect);
        var sagaPhase3 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase3Saga), dialect);

        using (var connection = MsSqlSystemDataClientConnectionBuilder.Build())
        {
            await connection.OpenAsync().ConfigureAwait(false);

            connection.ExecuteCommand(SagaScriptBuilder.BuildDropScript(sagaPhase1, dialect), "");
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase1, dialect), "");
            var phase1Schema = GetSchema(connection);
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase2, dialect), "");
            var phase2Schema = GetSchema(connection);
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase3, dialect), "");
            var phase3Schema = GetSchema(connection);

            CollectionAssert.Contains(phase1Schema, "Correlation_OrderNumber");
            CollectionAssert.DoesNotContain(phase1Schema, "Correlation_OrderId");

            CollectionAssert.Contains(phase2Schema, "Correlation_OrderNumber");
            CollectionAssert.Contains(phase2Schema, "Correlation_OrderId");

            CollectionAssert.DoesNotContain(phase3Schema, "Correlation_OrderNumber");
            CollectionAssert.Contains(phase3Schema, "Correlation_OrderId");
        }
    }
    public async Task Should_remove_old_property_after_phase_three()
    {
        var dialect    = BuildSqlDialect.Oracle;
        var sagaPhase1 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase1Saga), dialect);
        var sagaPhase2 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase2Saga), dialect);
        var sagaPhase3 = RuntimeSagaDefinitionReader.GetSagaDefinition(typeof(Phase3Saga), dialect);

        string[] phase1Schema, phase2Schema, phase3Schema;

        using (var connection = OracleConnectionBuilder.Build(disableMetadataPooling: true))
        {
            await connection.OpenAsync().ConfigureAwait(false);

            connection.ExecuteCommand(SagaScriptBuilder.BuildDropScript(sagaPhase1, dialect), "");
            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase1, dialect), "");
            phase1Schema = GetSchema(connection);

            connection.PurgeStatementCache();
        }

        using (var connection = OracleConnectionBuilder.Build(disableMetadataPooling: true))
        {
            await connection.OpenAsync().ConfigureAwait(false);

            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase2, dialect), "");
            phase2Schema = GetSchema(connection);

            connection.PurgeStatementCache();
        }

        using (var connection = OracleConnectionBuilder.Build(disableMetadataPooling: true))
        {
            await connection.OpenAsync().ConfigureAwait(false);

            connection.ExecuteCommand(SagaScriptBuilder.BuildCreateScript(sagaPhase3, dialect), "");
            phase3Schema = GetSchema(connection);

            connection.PurgeStatementCache();
        }

        CollectionAssert.Contains(phase1Schema, "CORR_ORDERNUMBER");
        CollectionAssert.DoesNotContain(phase1Schema, "CORR_ORDERID");

        CollectionAssert.Contains(phase2Schema, "CORR_ORDERNUMBER");
        CollectionAssert.Contains(phase2Schema, "CORR_ORDERID");

        CollectionAssert.DoesNotContain(phase3Schema, "CORR_ORDERNUMBER");
        CollectionAssert.Contains(phase3Schema, "CORR_ORDERID");
    }