Use option to select sqlite
This commit is contained in:
parent
972838d39b
commit
a5e377e66f
|
@ -452,3 +452,9 @@ $RECYCLE.BIN/
|
|||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
|
||||
# SqlLite
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
*.db
|
||||
|
|
|
@ -28,14 +28,17 @@ namespace BlueWest.WebApi
|
|||
IConfiguration configuration,
|
||||
IWebHostEnvironment environment)
|
||||
{
|
||||
var sqlVersion = GetMySqlServerVersion(8, 0, 11);
|
||||
|
||||
optionsBuilder
|
||||
.UseMySql(configuration.GetConnectionString("DockerMySQL"), GetMySqlServerVersion(8, 0, 11))
|
||||
.UseMySql(GetMySqlServerVersion(8, 0, 11),
|
||||
builder =>
|
||||
{
|
||||
builder.EnableRetryOnFailure(6, TimeSpan.FromSeconds(3), null);
|
||||
});
|
||||
.UseMySql(
|
||||
configuration.GetConnectionString("DockerMySQL"),
|
||||
sqlVersion)
|
||||
.UseMySql(sqlVersion,
|
||||
builder =>
|
||||
{
|
||||
builder.EnableRetryOnFailure(6, TimeSpan.FromSeconds(3), null);
|
||||
});
|
||||
|
||||
// The following three options help with debugging, but should
|
||||
// be changed or removed for production.
|
||||
|
@ -57,7 +60,7 @@ namespace BlueWest.WebApi
|
|||
/// <param name="configuration"></param>
|
||||
/// <param name="environment"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection PrepareMySQLDatabasePool(this IServiceCollection serviceCollection,
|
||||
public static IServiceCollection PrepareMySqlDatabasePool(this IServiceCollection serviceCollection,
|
||||
IConfiguration configuration, IWebHostEnvironment environment)
|
||||
{
|
||||
return serviceCollection
|
||||
|
@ -74,7 +77,7 @@ namespace BlueWest.WebApi
|
|||
/// <param name="configuration"></param>
|
||||
/// <param name="environment"></param>
|
||||
/// <returns></returns>
|
||||
public static IServiceCollection PrepareSQLLiteDatabasePool(this IServiceCollection serviceCollection,
|
||||
public static IServiceCollection PrepareSqlLiteDatabasePool(this IServiceCollection serviceCollection,
|
||||
IConfiguration configuration, IWebHostEnvironment environment)
|
||||
{
|
||||
return serviceCollection
|
||||
|
|
|
@ -60,20 +60,7 @@ namespace BlueWest.WebApi
|
|||
options.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "BlueWest.Api.App",
|
||||
Version = "v1",
|
||||
Description = "BlueWest.Api.App",
|
||||
TermsOfService = new Uri("https://git.codeliturgy.com/terms-of-service"),
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
Name = "Benny",
|
||||
Email = string.Empty,
|
||||
Url = new Uri("https://git.codeliturgy.com"),
|
||||
},
|
||||
License = new OpenApiLicense
|
||||
{
|
||||
Name = "Use under LICX",
|
||||
Url = new Uri("https://git.codeliturgy.com/license"),
|
||||
}
|
||||
Version = "v1"
|
||||
});
|
||||
|
||||
// Set the comments path for the Swagger JSON and UI.
|
||||
|
@ -92,15 +79,18 @@ namespace BlueWest.WebApi
|
|||
services
|
||||
.AddSingleton<EventManager>();
|
||||
|
||||
if (allowedDatabase == "mysql")
|
||||
switch (allowedDatabase)
|
||||
{
|
||||
services
|
||||
.PrepareMySQLDatabasePool(_configuration, _environment);
|
||||
}
|
||||
case "mysql":
|
||||
services.PrepareMySqlDatabasePool(_configuration, _environment);
|
||||
break;
|
||||
|
||||
if (allowedDatabase == "sqlite")
|
||||
{
|
||||
services.PrepareSQLLiteDatabasePool(_configuration, _environment);
|
||||
case "sqlite":
|
||||
services.PrepareSqlLiteDatabasePool(_configuration, _environment);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException("config.json doesn't specify a valid database. Use mysql or sqlite.");
|
||||
}
|
||||
|
||||
services.AddScoped<ExchangeInterface>();
|
||||
|
@ -110,6 +100,7 @@ namespace BlueWest.WebApi
|
|||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
/// </summary>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5006902892221cef14127637b20f6f59ae28a311
|
||||
Subproject commit ba851c4f946fd370f888a8aa902ac5f46a982e73
|
Loading…
Reference in New Issue