line-gestao-api/Migrations/20260212120000_AddAuditLogs.cs

73 lines
3.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace line_gestao_api.Migrations
{
/// <inheritdoc />
public partial class AddAuditLogs : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AuditLogs",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
OccurredAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: true),
UserName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
UserEmail = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
Action = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Page = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: false),
EntityName = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
EntityId = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
EntityLabel = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
ChangesJson = table.Column<string>(type: "jsonb", nullable: false),
RequestPath = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
RequestMethod = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: true),
IpAddress = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AuditLogs", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_EntityName",
table: "AuditLogs",
column: "EntityName");
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_OccurredAtUtc",
table: "AuditLogs",
column: "OccurredAtUtc");
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_Page",
table: "AuditLogs",
column: "Page");
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_TenantId",
table: "AuditLogs",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_UserId",
table: "AuditLogs",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AuditLogs");
}
}
}