Files
PowderCoatingLogix/src/PowderCoating.Infrastructure/Migrations/20260415120000_AddAuditLogTable.cs
T
2026-04-23 21:38:24 -04:00

57 lines
2.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddAuditLogTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AuditLogs",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserName = table.Column<string>(type: "nvarchar(max)", nullable: false),
CompanyId = table.Column<int>(type: "int", nullable: true),
CompanyName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Action = table.Column<string>(type: "nvarchar(max)", nullable: false),
EntityType = table.Column<string>(type: "nvarchar(450)", nullable: false),
EntityId = table.Column<string>(type: "nvarchar(450)", nullable: true),
EntityDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
OldValues = table.Column<string>(type: "nvarchar(max)", nullable: true),
NewValues = table.Column<string>(type: "nvarchar(max)", nullable: true),
IpAddress = table.Column<string>(type: "nvarchar(max)", nullable: true),
Timestamp = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AuditLogs", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_CompanyId_Timestamp",
table: "AuditLogs",
columns: new[] { "CompanyId", "Timestamp" });
migrationBuilder.CreateIndex(
name: "IX_AuditLogs_EntityType_EntityId",
table: "AuditLogs",
columns: new[] { "EntityType", "EntityId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AuditLogs");
}
}
}