Use PostgreSQL
This commit is contained in:
parent
f0caf1dbc4
commit
6a555652fb
|
@ -27,6 +27,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
|
||||||
<PackageReference Include="Npgsql" Version="7.0.0" />
|
<PackageReference Include="Npgsql" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ using CodeLiturgy.Views.Utils;
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
namespace CodeLiturgy.Views;
|
namespace CodeLiturgy.Views;
|
||||||
|
@ -147,51 +148,13 @@ public static class StartupExtensions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
private static DbContextOptionsBuilder UsePsqlConfiguration(this DbContextOptionsBuilder builder, IConfiguration configuration)
|
||||||
/// Get MYSQL Connection String
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="optionsBuilder"></param>
|
|
||||||
/// <param name="configuration"></param>
|
|
||||||
/// <param name="environment"></param>
|
|
||||||
/*
|
|
||||||
private static DbContextOptionsBuilder GetMySqlSettings(
|
|
||||||
this DbContextOptionsBuilder optionsBuilder,
|
|
||||||
IConfiguration configuration,
|
|
||||||
IWebHostEnvironment environment)
|
|
||||||
{
|
{
|
||||||
var sqlVersion = GetMySqlServerVersion(8, 0, 11);
|
var connString = configuration.GetConnectionString("database");
|
||||||
|
builder.UseNpgsql(connString);
|
||||||
// Docker / No-Docker
|
return builder;
|
||||||
|
|
||||||
|
|
||||||
var mySqlConnectionString = configuration.GetConnectionString("MySQL");
|
|
||||||
|
|
||||||
if (mySqlConnectionString == string.Empty)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("MySQL Connection string appears to be empty.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
optionsBuilder
|
|
||||||
.UseMySql(
|
|
||||||
mySqlConnectionString,
|
|
||||||
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.
|
|
||||||
if (environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
optionsBuilder
|
|
||||||
.LogTo(Console.WriteLine, LogLevel.Information)
|
|
||||||
.EnableSensitiveDataLogging()
|
|
||||||
.EnableDetailedErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
return optionsBuilder;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Setup database Contexts
|
/// Setup database Contexts
|
||||||
|
@ -203,13 +166,11 @@ public static class StartupExtensions
|
||||||
public static IServiceCollection PreparePostgresqlDatabasePool(this IServiceCollection serviceCollection,
|
public static IServiceCollection PreparePostgresqlDatabasePool(this IServiceCollection serviceCollection,
|
||||||
IConfiguration configuration, IWebHostEnvironment environment)
|
IConfiguration configuration, IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
return serviceCollection;
|
return serviceCollection
|
||||||
/*.AddDbContextPool<UserDbContext>(options =>
|
.AddDbContextPool<UserDbContext>(options => options.UsePsqlConfiguration(configuration))
|
||||||
options.GetMySqlSettings(configuration, environment))
|
.AddDbContextPool<CountryDbContext>(options => options.UsePsqlConfiguration(configuration))
|
||||||
.AddDbContextPool<CountryDbContext>(options =>
|
|
||||||
options.GetMySqlSettings(configuration, environment))
|
|
||||||
.AddDbContextPool<ApplicationUserDbContext>(options =>
|
.AddDbContextPool<ApplicationUserDbContext>(options =>
|
||||||
options.GetMySqlSettings(configuration, environment));*/
|
options.UsePsqlConfiguration(configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
"mode": "no-docker",
|
"mode": "no-docker",
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStringDocker": {
|
"ConnectionStringDocker": {
|
||||||
"MySQL": "server=db;user=blueuser;password=dXjw127124dJ;database=bluedb;"
|
"database": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;"
|
||||||
},
|
},
|
||||||
"ConnectionStringNoDocker": {
|
"ConnectionStringNoDocker": {
|
||||||
"MySQL": "server=localhost;user=blueuser;password=dXjw127124dJ;database=bluedb;"
|
"database": "Server=127.0.0.1;User Id=clbdlocal;Password=C79J#MV))!YAiy/SzkCf;Database=cldblocal;"
|
||||||
},
|
},
|
||||||
"AuthSettings": {
|
"AuthSettings": {
|
||||||
"SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH"
|
"SecretKey": "iJWHDmHLpUA283sqsfhqGbMRdRj1PVkH"
|
||||||
|
|
Loading…
Reference in New Issue