<commit_before>using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace SimpleSoft.Database.Migrator.Tests.Relational.SqlServer
{
    public class EmptySqlServerMigrationManagerTests: IClassFixture<EmptyDatabaseFixture>
    {
        private readonly EmptyDatabaseFixture _fixture;

        public EmptySqlServerMigrationManagerTests(EmptyDatabaseFixture fixture)
        {
            _fixture = fixture;
        }

        [Fact]
        public async Task GivenAnEmptyDatabaseWhenPreparingForMigrationsThenATableMustBeCreated()
        {
            var ct = CancellationToken.None;

            var manager = new SqlServerMigrationManager<MigratorTestContext>(
                _fixture.Context, new DefaultNamingNormalizer(), 
                LoggingManager.CreateTestLogger<SqlServerMigrationManager<MigratorTestContext>>());

            await manager.PrepareDatabaseAsync(ct);

            var tableId = await manager.Context.RunAsync(async () =>
                await manager.Context.QuerySingleAsync<long>(@"
select count(*) as Total
from (
	select 
        MigrationId, ClassName, AppliedOn
	from __DbMigratorHistory
) V"), true, ct);
            Assert.NotNull(tableId);
            Assert.Equal(0L, tableId);
        }
    }
}<commit_msg>Making sure all columns exist<commit_after>using System.Threading;
using System.Threading.Tasks;
using Xunit;

namespace SimpleSoft.Database.Migrator.Tests.Relational.SqlServer
{
    public class EmptySqlServerMigrationManagerTests: IClassFixture<EmptyDatabaseFixture>
    {
        private readonly EmptyDatabaseFixture _fixture;

        public EmptySqlServerMigrationManagerTests(EmptyDatabaseFixture fixture)
        {
            _fixture = fixture;
        }

        [Fact]
        public async Task GivenAnEmptyDatabaseWhenPreparingForMigrationsThenATableMustBeCreated()
        {
            var ct = CancellationToken.None;

            var manager = new SqlServerMigrationManager<MigratorTestContext>(
                _fixture.Context, new DefaultNamingNormalizer(), 
                LoggingManager.CreateTestLogger<SqlServerMigrationManager<MigratorTestContext>>());

            await manager.PrepareDatabaseAsync(ct);

            var tableId = await manager.Context.RunAsync(async () =>
                await manager.Context.QuerySingleAsync<long>(@"
select count(*) as Total
from (
	select 
        --  making sure all columns exist
        ContextName, MigrationId, ClassName, AppliedOn
	from __DbMigratorHistory
) V"), true, ct);
            Assert.NotNull(tableId);
            Assert.Equal(0L, tableId);
        }
    }
}
{'fraction_non_alphanumeric': 0.0746840291076216, 'fraction_numerical': 0.0007659900421294523, 'mean_word_length': 2.9278195488721805, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2149575', 'n_tokens_mistral': 696, 'n_tokens_neox': 676, 'n_words': 134}