Some checks are pending
Базовый domain-каркас для SuperAdmin console (Phase 1): Organization: - IsArchived bool + ArchivedAt DateTime? — архивная орга не видна юзерам, но данные сохраняются. Удалить навсегда можно только из архива >30 дней (логика в API на следующем коммите). - AccountOwnerUserId Guid? — главный владелец, не путать с админами per-org. SuperAdmin может сменить через action c reason в audit-log. - HasIndex(IsArchived) для быстрой фильтрации. SuperAdminAuditLog (новая таблица super_admin_audit_log): - Не tenant-scoped — лог общий по всей системе. - ActionType (CreateOrg/EditOrg/ArchiveOrg/RestoreOrg/DeleteOrg/ ChangeOwner/EditEntity), OrganizationId, EntityType+EntityId, Description, Reason, ChangesJson (jsonb), IpAddress. - Индексы: CreatedAt, (SuperAdminUserId, CreatedAt), (OrganizationId, CreatedAt) — типовые запросы фильтра. Migration Phase4_SuperAdminConsole добавляет 3 колонки в organizations + создаёт super_admin_audit_log с тремя композитными индексами. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
72 lines
4 KiB
C#
72 lines
4 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
||
|
||
#nullable disable
|
||
|
||
namespace foodmarket.Infrastructure.Persistence.Migrations
|
||
{
|
||
/// <summary>SuperAdmin console: organizations.IsArchived/ArchivedAt/
|
||
/// AccountOwnerUserId + новая таблица super_admin_audit_log для журнала
|
||
/// действий супер-админа (создание/правка/архивирование орг,
|
||
/// смена аккаунт-владельца, правки в режиме «войти как»).</summary>
|
||
public partial class Phase4_SuperAdminConsole : Migration
|
||
{
|
||
protected override void Up(MigrationBuilder b)
|
||
{
|
||
b.AddColumn<bool>(
|
||
name: "IsArchived", schema: "public", table: "organizations",
|
||
type: "boolean", nullable: false, defaultValue: false);
|
||
b.AddColumn<System.DateTime>(
|
||
name: "ArchivedAt", schema: "public", table: "organizations",
|
||
type: "timestamp with time zone", nullable: true);
|
||
b.AddColumn<System.Guid>(
|
||
name: "AccountOwnerUserId", schema: "public", table: "organizations",
|
||
type: "uuid", nullable: true);
|
||
b.CreateIndex(
|
||
name: "IX_organizations_IsArchived",
|
||
schema: "public",
|
||
table: "organizations",
|
||
column: "IsArchived");
|
||
|
||
b.CreateTable(
|
||
name: "super_admin_audit_log",
|
||
schema: "public",
|
||
columns: table => new
|
||
{
|
||
Id = table.Column<System.Guid>(type: "uuid", nullable: false),
|
||
SuperAdminUserId = table.Column<System.Guid>(type: "uuid", nullable: false),
|
||
ActionType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||
OrganizationId = table.Column<System.Guid>(type: "uuid", nullable: true),
|
||
EntityType = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
|
||
EntityId = table.Column<System.Guid>(type: "uuid", nullable: true),
|
||
Description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
|
||
Reason = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
||
ChangesJson = table.Column<string>(type: "jsonb", nullable: false),
|
||
IpAddress = table.Column<string>(type: "character varying(45)", maxLength: 45, nullable: false),
|
||
CreatedAt = table.Column<System.DateTime>(type: "timestamp with time zone", nullable: false),
|
||
UpdatedAt = table.Column<System.DateTime>(type: "timestamp with time zone", nullable: true),
|
||
},
|
||
constraints: table => table.PrimaryKey("PK_super_admin_audit_log", x => x.Id));
|
||
b.CreateIndex(
|
||
name: "IX_super_admin_audit_log_CreatedAt",
|
||
schema: "public", table: "super_admin_audit_log", column: "CreatedAt");
|
||
b.CreateIndex(
|
||
name: "IX_super_admin_audit_log_SuperAdminUserId_CreatedAt",
|
||
schema: "public", table: "super_admin_audit_log",
|
||
columns: new[] { "SuperAdminUserId", "CreatedAt" });
|
||
b.CreateIndex(
|
||
name: "IX_super_admin_audit_log_OrganizationId_CreatedAt",
|
||
schema: "public", table: "super_admin_audit_log",
|
||
columns: new[] { "OrganizationId", "CreatedAt" });
|
||
}
|
||
|
||
protected override void Down(MigrationBuilder b)
|
||
{
|
||
b.DropTable(name: "super_admin_audit_log", schema: "public");
|
||
b.DropIndex(name: "IX_organizations_IsArchived", schema: "public", table: "organizations");
|
||
b.DropColumn(name: "AccountOwnerUserId", schema: "public", table: "organizations");
|
||
b.DropColumn(name: "ArchivedAt", schema: "public", table: "organizations");
|
||
b.DropColumn(name: "IsArchived", schema: "public", table: "organizations");
|
||
}
|
||
}
|
||
}
|