forked from xiongyuxing/tiku-backend.net
feat: 添加租户隔离保护触发器的管理方法,并更新迁移文档
This commit is contained in:
@@ -9200,14 +9200,13 @@ namespace Tiku.Infrastructure.Persistence.Migrations
|
||||
principalColumns: new[] { "tenant_id", "id" },
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.CreateTenantQuestionReferenceGuard);
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.CreateTaxonomyParentGuard);
|
||||
migrationBuilder.EnsureTenantIsolationGuards();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.DropTenantGuards);
|
||||
migrationBuilder.DropTenantIsolationGuards();
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_content_entries_regions_tenant_id_region_id",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Tiku.Infrastructure.Persistence.Migrations;
|
||||
|
||||
internal static class MigrationBuilderTenantGuardExtensions
|
||||
{
|
||||
public static void EnsureTenantIsolationGuards(this MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.DropTenantGuards);
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.CreateTenantQuestionReferenceGuard);
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.CreateTaxonomyParentGuard);
|
||||
}
|
||||
|
||||
public static void DropTenantIsolationGuards(this MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(PostgreSqlTenantConstraintSql.DropTenantGuards);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user