Skip to content

Commit

Permalink
Bug #509: Migration fails if default output folder ("output" in curre…
Browse files Browse the repository at this point in the history
…nt directory) is not writable (#510)

* Created concept for running unit tests with grate in docker.
* Added docker tests for all databases

* Fixed problem with the internal migrations not obeying the output folder
* Removed requirement of output folder already existing before migrating

( WIP: Working on docker publish to container instead of Dockerfile - not done yet)
  • Loading branch information
erikbra authored May 7, 2024
1 parent 14e4ea4 commit fcb9cfb
Show file tree
Hide file tree
Showing 63 changed files with 1,391 additions and 151 deletions.
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"sdk": {
"version": "8.0.100",
"version": "8.0.200",
"allowPrerelease": false,
"rollForward": "major"
},
"tools": {
"dotnet": "8.0.100",
"dotnet": "8.0.200",
"runtimes": {
"aspnetcore": [
"6.0.25",
Expand Down
93 changes: 93 additions & 0 deletions grate.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine.PostgreSQL", "u
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine.SqlServer", "unittests\CommandLine\CommandLine.SqlServer\CommandLine.SqlServer.csproj", "{3CD81B8C-9348-4F45-9E50-12713D47B1FB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker tests", "Docker tests", "{1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docker.SqlServer", "unittests\Docker\Docker.SqlServer\Docker.SqlServer.csproj", "{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docker.MariaDB", "unittests\Docker\Docker.MariaDB\Docker.MariaDB.csproj", "{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docker.Common", "unittests\Docker\Docker.Common\Docker.Common.csproj", "{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docker.Sqlite", "unittests\Docker\Docker.Sqlite\Docker.Sqlite.csproj", "{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docker.Oracle", "unittests\Docker\Docker.Oracle\Docker.Oracle.csproj", "{11D21F9B-1819-4C5D-A032-E556520FF607}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docker.PostgreSQL", "unittests\Docker\Docker.PostgreSQL\Docker.PostgreSQL.csproj", "{542958B4-117C-4E00-A555-00B9630A7066}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -322,6 +336,78 @@ Global
{3CD81B8C-9348-4F45-9E50-12713D47B1FB}.Release|x64.Build.0 = Release|Any CPU
{3CD81B8C-9348-4F45-9E50-12713D47B1FB}.Release|x86.ActiveCfg = Release|Any CPU
{3CD81B8C-9348-4F45-9E50-12713D47B1FB}.Release|x86.Build.0 = Release|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Debug|x64.ActiveCfg = Debug|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Debug|x64.Build.0 = Debug|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Debug|x86.ActiveCfg = Debug|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Debug|x86.Build.0 = Debug|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Release|Any CPU.Build.0 = Release|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Release|x64.ActiveCfg = Release|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Release|x64.Build.0 = Release|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Release|x86.ActiveCfg = Release|Any CPU
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9}.Release|x86.Build.0 = Release|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Debug|x64.ActiveCfg = Debug|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Debug|x64.Build.0 = Debug|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Debug|x86.ActiveCfg = Debug|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Debug|x86.Build.0 = Debug|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Release|Any CPU.Build.0 = Release|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Release|x64.ActiveCfg = Release|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Release|x64.Build.0 = Release|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Release|x86.ActiveCfg = Release|Any CPU
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E}.Release|x86.Build.0 = Release|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Debug|x64.ActiveCfg = Debug|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Debug|x64.Build.0 = Debug|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Debug|x86.ActiveCfg = Debug|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Debug|x86.Build.0 = Debug|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Release|Any CPU.Build.0 = Release|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Release|x64.ActiveCfg = Release|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Release|x64.Build.0 = Release|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Release|x86.ActiveCfg = Release|Any CPU
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2}.Release|x86.Build.0 = Release|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Debug|x64.ActiveCfg = Debug|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Debug|x64.Build.0 = Debug|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Debug|x86.ActiveCfg = Debug|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Debug|x86.Build.0 = Debug|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Release|Any CPU.Build.0 = Release|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Release|x64.ActiveCfg = Release|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Release|x64.Build.0 = Release|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Release|x86.ActiveCfg = Release|Any CPU
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10}.Release|x86.Build.0 = Release|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Debug|x64.ActiveCfg = Debug|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Debug|x64.Build.0 = Debug|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Debug|x86.ActiveCfg = Debug|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Debug|x86.Build.0 = Debug|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Release|Any CPU.Build.0 = Release|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Release|x64.ActiveCfg = Release|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Release|x64.Build.0 = Release|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Release|x86.ActiveCfg = Release|Any CPU
{11D21F9B-1819-4C5D-A032-E556520FF607}.Release|x86.Build.0 = Release|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Debug|Any CPU.Build.0 = Debug|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Debug|x64.ActiveCfg = Debug|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Debug|x64.Build.0 = Debug|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Debug|x86.ActiveCfg = Debug|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Debug|x86.Build.0 = Debug|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Release|Any CPU.ActiveCfg = Release|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Release|Any CPU.Build.0 = Release|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Release|x64.ActiveCfg = Release|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Release|x64.Build.0 = Release|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Release|x86.ActiveCfg = Release|Any CPU
{542958B4-117C-4E00-A555-00B9630A7066}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -352,5 +438,12 @@ Global
{BD31AD42-D1A0-4131-9DD5-7DA83F3F34A8} = {04731BDA-05F0-4275-AC70-3E60E87F9461}
{89CBE842-BD34-4833-96B4-9E410C5C6AD7} = {04731BDA-05F0-4275-AC70-3E60E87F9461}
{3CD81B8C-9348-4F45-9E50-12713D47B1FB} = {04731BDA-05F0-4275-AC70-3E60E87F9461}
{1F3AC4DA-B220-4DD7-ACD4-B309B60A5910} = {CE4BF96D-E795-49EC-BB36-EDCC7E542685}
{26A2069A-ECE7-46A3-8CDC-8D864062B1E9} = {1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}
{9134186E-F1A8-4582-BF61-7DDC79D7BF2E} = {1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}
{E16F876A-A2A0-46FB-9FEA-C0C64DAB89D2} = {1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}
{73EBC3A0-E8DC-4AC1-8788-FE7DB3F53C10} = {1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}
{11D21F9B-1819-4C5D-A032-E556520FF607} = {1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}
{542958B4-117C-4E00-A555-00B9630A7066} = {1F3AC4DA-B220-4DD7-ACD4-B309B60A5910}
EndGlobalSection
EndGlobal
26 changes: 16 additions & 10 deletions installers/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build

ARG os=linux-musl
ARG arch=amd64
ENV OS $os
ENV ARCH $arch

WORKDIR .
COPY *.props ./
COPY *.ruleset ./
COPY src/ ./src/
RUN dotnet publish ./src/grate/grate.csproj -r linux-musl-x64 -c release --self-contained -p:SelfContained=true -o ./publish/app
RUN dotnet publish ./src/grate/grate.csproj --os $OS --arch $ARCH -c release --self-contained -p:SelfContained=true -o ./publish/app

FROM alpine:3 AS base
WORKDIR /app
Expand All @@ -16,12 +22,12 @@ ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

# Add the grate executable
ENTRYPOINT ./grate \
--sqlfilesdirectory=/db \
--version=${VERSION:-1.0.0} \
--connstring="$APP_CONNSTRING" \
--databasetype=${DATABASE_TYPE:-sqlserver} \
--silent \
--outputPath=/output \
--createdatabase=${CREATE_DATABASE:-true} \
--environment=${ENVIRONMENT:-LOCAL} \
--transaction=${TRANSACTION:-false}
--sqlfilesdirectory=/db \
--version=${VERSION:-1.0.0} \
--connstring="$APP_CONNSTRING" \
--databasetype=${DATABASE_TYPE:-sqlserver} \
--silent \
--outputPath=/output \
--createdatabase=${CREATE_DATABASE:-true} \
--environment=${ENVIRONMENT:-LOCAL} \
--transaction=${TRANSACTION:-false}
4 changes: 3 additions & 1 deletion src/grate.core/Configuration/FoldersCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using grate.Exceptions;

namespace grate.Configuration;
Expand Down Expand Up @@ -135,6 +136,7 @@ private static void ApplyConfig(MigrationsFolder folder, string folderConfig)
}
}

[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)]
static readonly Type FolderType = typeof(MigrationsFolder);

private static (MethodInfo? setter, Type? propertyType) GetProperty(string propertyName)
Expand Down
11 changes: 6 additions & 5 deletions src/grate.core/DependencyInjection/RegistrationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using grate.Configuration;
using System.Diagnostics.CodeAnalysis;
using grate.Configuration;
using grate.Infrastructure;
using grate.Migration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -36,7 +37,7 @@ public static IServiceCollection AddGrate(this IServiceCollection serviceCollect
return AddGrateService(serviceCollection);
}

public static IServiceCollection AddGrate<TDatabase>(
public static IServiceCollection AddGrate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TDatabase>(
this IServiceCollection serviceCollection, GrateConfiguration presetGrateConfiguration, Action<GrateConfigurationBuilder>? builder = null)
where TDatabase : class, IDatabase
{
Expand All @@ -45,7 +46,7 @@ public static IServiceCollection AddGrate<TDatabase>(
.UseDatabase<TDatabase>();
}

public static IServiceCollection AddGrate<TDatabase>(
public static IServiceCollection AddGrate<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TDatabase>(
this IServiceCollection serviceCollection, Action<GrateConfigurationBuilder>? builder = null)
where TDatabase : class, IDatabase
{
Expand All @@ -54,14 +55,14 @@ public static IServiceCollection AddGrate<TDatabase>(
.UseDatabase<TDatabase>();
}

public static IServiceCollection UseDatabase<TDatabase>(this IServiceCollection serviceCollection)
public static IServiceCollection UseDatabase<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TDatabase>(this IServiceCollection serviceCollection)
where TDatabase : class, IDatabase
{
serviceCollection.TryAddTransient<IDatabase, TDatabase>();
return serviceCollection;
}

public static IServiceCollection UseDatabase(this IServiceCollection serviceCollection, Type databaseType)
public static IServiceCollection UseDatabase(this IServiceCollection serviceCollection, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type databaseType)
{
serviceCollection.TryAddTransient(typeof(IDatabase), databaseType);
return serviceCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/grate.core/Migration/AnsiSqlDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private async Task<IDictionary<string, string>> GetAllScriptsRun()
}
catch (Exception ex) when (DryRunOrBootstrap())
{
Logger.LogDebug(ex, "Ignoring error getting ScriptsRun when in --dryrun, probable missing table");
Logger.LogDebug(ex, "Ignoring error getting ScriptsRun when in --dryrun, probably missing table");
return new Dictionary<string, string>(); // return empty set if nothing has ever been run
}
}
Expand Down
27 changes: 21 additions & 6 deletions src/grate.core/Migration/GrateMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public async Task Migrate()
var runInTransaction = MakeSureWeCanRunInTransaction(config.Transaction, silent, dbMigrator);

var changeDropFolder = ChangeDropFolder(config, database.ServerName, database.DatabaseName);
_logger.LogDebug("The change_drop (output) folder is: {ChangeDropFolder}", changeDropFolder);

CreateChangeDropFolder(changeDropFolder);

_logger.LogDebug("The change_drop (output) folder is: {ChangeDropFolder}", changeDropFolder);
Separator('=');

_logger.LogInformation("Setup, Backup, Create/Restore/Drop");
Expand Down Expand Up @@ -573,19 +574,28 @@ private async Task RunInternalMigrations(string internalFolderName)
}
}

private async Task<GrateConfiguration> GetBootstrapInternalGrateConfiguration(string internalFolderName) =>
await GetInternalGrateConfiguration(internalFolderName, "grate-internal") with
private async Task<GrateConfiguration> GetBootstrapInternalGrateConfiguration(string internalFolderName)
{
var bootstrapInternalGrateConfiguration = await GetInternalGrateConfiguration(internalFolderName, "grate-internal") with
{
UserTokens = [
UserTokens =
[
"ScriptsRunTable=GrateScriptsRun",
"ScriptsRunErrorsTable=GrateScriptsRunErrors",
"VersionTable=GrateVersion"
],
DeferWritingToRunTables = true,
Environment = GrateEnvironment.InternalBootstrap,
Baseline = false
Baseline = false,
};

bootstrapInternalGrateConfiguration = bootstrapInternalGrateConfiguration with
{
OutputPath = bootstrapInternalGrateConfiguration.OutputPath.Parent!.CreateSubdirectory("grate-internal-bootstrap")
};

return bootstrapInternalGrateConfiguration;
}

private async Task<GrateConfiguration> GetInternalGrateConfiguration(string internalFolderName, string? sqlFolderNamePrefix = null)
{
var thisConfig = this.Configuration;
Expand All @@ -606,11 +616,16 @@ private async Task<GrateConfiguration> GetInternalGrateConfiguration(string inte
AccessToken = thisConfig.AccessToken,
CommandTimeout = thisConfig.CommandTimeout,
AdminCommandTimeout = thisConfig.AdminCommandTimeout,
Verbosity = LogLevel.Critical,
OutputPath = thisConfig.OutputPath.CreateSubdirectory("grate-internal"),

Baseline = baseline,
NonInteractive = true,
SqlFilesDirectory = new DirectoryInfo(internalMigrationFolders),
CreateDatabase = false,
AlterDatabase = false,
DryRun = false,

Drop = false,
Restore = null,
Transaction = false,
Expand Down
9 changes: 9 additions & 0 deletions src/grate.core/grate.core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<RootNamespace>grate</RootNamespace>
<SourceRevisionId>build$([System.DateTime]::UtcNow.ToString("O"))</SourceRevisionId>

</PropertyGroup>

<ItemGroup>
Expand All @@ -17,11 +18,19 @@
<InternalsVisibleTo Include="Sqlite" />
<InternalsVisibleTo Include="SqlServer" />
<InternalsVisibleTo Include="SqlServerCaseSensitive" />

<InternalsVisibleTo Include="CommandLine.MariaDB" />
<InternalsVisibleTo Include="CommandLine.Oracle" />
<InternalsVisibleTo Include="CommandLine.PostgreSQL" />
<InternalsVisibleTo Include="CommandLine.Sqlite" />
<InternalsVisibleTo Include="CommandLine.SqlServer" />

<InternalsVisibleTo Include="Docker.MariaDB" />
<InternalsVisibleTo Include="Docker.Oracle" />
<InternalsVisibleTo Include="Docker.PostgreSQL" />
<InternalsVisibleTo Include="Docker.Sqlite" />
<InternalsVisibleTo Include="Docker.SqlServer" />

</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/grate/Commands/MigrateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static Option OutputPath() =>
new[] { "--output", "-o", "--outputPath" },
() => new DirectoryInfo(DefaultOutputPath),
"This is where everything related to the migration is stored. This includes any backups, all items that ran, permission dumps, logs, etc."
).ExistingOnly();
);

private static Option Folders() =>
new Option<IFoldersConfiguration>(
Expand Down
15 changes: 11 additions & 4 deletions src/grate/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,17 @@ private static async Task WaitForLoggerToFinish()
var delay = 100;

await Task.Delay(1);
while (ThreadPool.PendingWorkItemCount > 0 && waitedTime < maxWaitTime)
try
{
await Task.Delay(delay);
waitedTime += delay;
while (ThreadPool.PendingWorkItemCount > 0 && waitedTime < maxWaitTime)
{
await Task.Delay(delay);
waitedTime += delay;
}
}
catch (Exception)
{
// We don't want to fail on exit. Nevermind, just exit, and get on with it.
}
}

Expand Down Expand Up @@ -136,7 +143,7 @@ private static ServiceProvider BuildServiceProvider(CommandLineGrateConfiguratio
return services.BuildServiceProvider();
}

private static Option<LogLevel> Verbosity() => new(
internal static Option<LogLevel> Verbosity() => new(
new[] { "-v", "--verbosity" },
"Verbosity level (as defined here: https://docs.microsoft.com/dotnet/api/Microsoft.Extensions.Logging.LogLevel)");

Expand Down
Loading

0 comments on commit fcb9cfb

Please sign in to comment.