forked from xiongyuxing/tiku-backend.net
feat: 添加租户隔离保护触发器的管理方法,并更新迁移文档
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Tiku.IntegrationTests.Api;
|
||||
using Tiku.Infrastructure.Persistence;
|
||||
@@ -22,4 +24,22 @@ public sealed class MigrationExecutionTests
|
||||
Assert.NotEmpty(appliedMigrations);
|
||||
Assert.True(await dbContext.Database.CanConnectAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Migration_script_contains_tenant_isolation_guard_triggers()
|
||||
{
|
||||
await using var factory = new ApiTestFactory();
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<TikuDbContext>();
|
||||
var migrator = dbContext.GetService<IMigrator>();
|
||||
|
||||
var script = migrator.GenerateScript();
|
||||
|
||||
Assert.Contains("drop trigger if exists trg_tenant_question_references_platform_or_self_owner", script);
|
||||
Assert.Contains("create or replace function tiku_guard_tenant_question_reference()", script);
|
||||
Assert.Contains("create trigger trg_tenant_question_references_platform_or_self_owner", script);
|
||||
Assert.Contains("drop trigger if exists trg_taxonomy_nodes_parent_platform_or_self_owner", script);
|
||||
Assert.Contains("create or replace function tiku_guard_taxonomy_parent_owner()", script);
|
||||
Assert.Contains("create trigger trg_taxonomy_nodes_parent_platform_or_self_owner", script);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user