using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace foodmarket.Infrastructure.Persistence.Migrations { /// SuperAdmin console: organizations.IsArchived/ArchivedAt/ /// AccountOwnerUserId + новая таблица super_admin_audit_log для журнала /// действий супер-админа (создание/правка/архивирование орг, /// смена аккаунт-владельца, правки в режиме «войти как»). public partial class Phase4_SuperAdminConsole : Migration { protected override void Up(MigrationBuilder b) { b.AddColumn( name: "IsArchived", schema: "public", table: "organizations", type: "boolean", nullable: false, defaultValue: false); b.AddColumn( name: "ArchivedAt", schema: "public", table: "organizations", type: "timestamp with time zone", nullable: true); b.AddColumn( 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(type: "uuid", nullable: false), SuperAdminUserId = table.Column(type: "uuid", nullable: false), ActionType = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), OrganizationId = table.Column(type: "uuid", nullable: true), EntityType = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), EntityId = table.Column(type: "uuid", nullable: true), Description = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), Reason = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), ChangesJson = table.Column(type: "jsonb", nullable: false), IpAddress = table.Column(type: "character varying(45)", maxLength: 45, nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(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"); } } }