38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using APT.BaseData.Domain.Entities;
|
|
using APT.Infrastructure.Api;
|
|
using APT.Infrastructure.Core;
|
|
using APT.Migrations;
|
|
using APT.Utility;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace APT.PF.WebApiControllers.Api.PF
|
|
{
|
|
[Route("api/PF/DbMigration")]
|
|
public class DbMigrationController : AuthorizeTreeApiController<T_PF_MENU>
|
|
{
|
|
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="pageFilter"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("Migrate")]
|
|
public JsonActionResult<bool> Migrate([FromBody] KeywordFilter filter)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
var tenantInfo = APT.Infrastructure.Api.ServiceLocator.Instance.GetService<TenantInfo>();
|
|
if (tenantInfo != null && !string.IsNullOrEmpty(tenantInfo.Conn))
|
|
{
|
|
using (var context = new MigrationContext(tenantInfo.Conn))
|
|
{
|
|
context.Database.Migrate();
|
|
}
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|