using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace mws.backend.dotnet.infrastructure.Migrations { /// public partial class AddAuditLogs : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "action_logs", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ActorUserId = table.Column(type: "uuid", nullable: false), ActorUsername = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Action = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), EntityType = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), EntityId = table.Column(type: "uuid", nullable: true), EntityName = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), IpAddress = table.Column(type: "character varying(45)", maxLength: 45, nullable: true), UserAgent = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_action_logs", x => x.Id); }); migrationBuilder.CreateTable( name: "login_logs", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Username = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), UserId = table.Column(type: "uuid", nullable: true), Success = table.Column(type: "boolean", nullable: false), FailureReason = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), IpAddress = table.Column(type: "character varying(45)", maxLength: 45, nullable: true), UserAgent = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_login_logs", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_action_logs_Action", table: "action_logs", column: "Action"); migrationBuilder.CreateIndex( name: "IX_action_logs_ActorUserId", table: "action_logs", column: "ActorUserId"); migrationBuilder.CreateIndex( name: "IX_action_logs_CreatedAt", table: "action_logs", column: "CreatedAt"); migrationBuilder.CreateIndex( name: "IX_action_logs_EntityType", table: "action_logs", column: "EntityType"); migrationBuilder.CreateIndex( name: "IX_login_logs_CreatedAt", table: "login_logs", column: "CreatedAt"); migrationBuilder.CreateIndex( name: "IX_login_logs_Success", table: "login_logs", column: "Success"); migrationBuilder.CreateIndex( name: "IX_login_logs_Username", table: "login_logs", column: "Username"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "action_logs"); migrationBuilder.DropTable( name: "login_logs"); } } }