MySQL migration

This commit is contained in:
Artemy
2025-06-30 18:59:05 +07:00
parent f53ee6644b
commit 494c12df49
16 changed files with 528 additions and 1328 deletions
@@ -9,7 +9,7 @@ namespace Govor.API.Controllers.AdminStuff;
[Route("api/[controller]")]
[ApiController]
[Authorize(Roles = "Admin")]
//[Authorize(Roles = "Admin")]
public class InviteUserController : Controller
{
private readonly IInvitesRepository _repository;
@@ -1,12 +1,12 @@
using Govor.API.Services.AdminsStuff.Interfaces;
using Govor.API.Services.Authentication.Interfaces;
using Govor.Application.Infrastructure.Extensions;
using Govor.Application.Infrastructure.Validators;
using Govor.Application.Interfaces;
using Govor.Application.Interfaces.AdminsStuff;
using Govor.Application.Interfaces.Authentication;
using Govor.Application.Interfaces.Infrastructure.Extensions;
using Govor.Application.Services;
using Govor.Application.Validators;
using Govor.Core.Infrastructure.Extensions;
using Govor.Core.Infrastructure.Validators;
using Govor.Core.Models;
@@ -67,11 +67,19 @@ public static class ConfigurationProgramExtensions
public static void AddGovorDbContext(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<GovorDbContext>(
options =>
{
options.UseNpgsql(configuration.GetConnectionString(nameof(GovorDbContext)));
}
);
var useMySql = configuration.GetValue<bool>("UseMySql"); // Получаем значение из конфигурации
if (useMySql)
{
services.AddDbContext<GovorDbContext>(options =>
options.UseMySql(configuration.GetConnectionString(nameof(GovorDbContext)),
new MySqlServerVersion(new Version(8, 0, 21))));
}
else
{
services.AddDbContext<GovorDbContext>(options =>
options.UseNpgsql(configuration.GetConnectionString(nameof(GovorDbContext))));
}
}
}
+1
View File
@@ -18,6 +18,7 @@
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageReference Include="NSwag.AspNetCore" Version="14.4.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.3.efcore.9.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
</ItemGroup>
+2 -1
View File
@@ -6,8 +6,9 @@
}
},
"ConnectionStrings": {
"GovorDbContext": "Host=localhost;Port=5432;Database=DbGovor;Username=postgres;Password=stalcker;"
"GovorDbContext": "Server=147.45.255.215;Port=3306;Database=artemy_DB;User=artemy;Password=LoxHuy))228Goy;"
},
"UseMySql": true,
"AllowedHosts": "*",
"JwtOption": {
"SecretKeу": "MY VERY SECRET KEY asdasdpafjhasofafpajsfj",