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