line-gestao-api/Migrations/20260213120000_AddImportAud...

102 lines
4.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace line_gestao_api.Migrations
{
/// <inheritdoc />
public partial class AddImportAuditTables : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ImportAuditRuns",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
ImportedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
FileName = table.Column<string>(type: "character varying(260)", maxLength: 260, nullable: true),
Status = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
CanonicalTotalLinhas = table.Column<int>(type: "integer", nullable: false),
SourceMaxItemGeral = table.Column<int>(type: "integer", nullable: false),
SourceValidCountGeral = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ImportAuditRuns", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ImportAuditIssues",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
AuditRunId = table.Column<Guid>(type: "uuid", nullable: false),
Entity = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
FieldName = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
SourceValue = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: true),
CanonicalValue = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
Resolution = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: false),
Severity = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ImportAuditIssues", x => x.Id);
table.ForeignKey(
name: "FK_ImportAuditIssues_ImportAuditRuns_AuditRunId",
column: x => x.AuditRunId,
principalTable: "ImportAuditRuns",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ImportAuditIssues_AuditRunId",
table: "ImportAuditIssues",
column: "AuditRunId");
migrationBuilder.CreateIndex(
name: "IX_ImportAuditIssues_Entity",
table: "ImportAuditIssues",
column: "Entity");
migrationBuilder.CreateIndex(
name: "IX_ImportAuditIssues_TenantId",
table: "ImportAuditIssues",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_ImportAuditRuns_ImportedAt",
table: "ImportAuditRuns",
column: "ImportedAt");
migrationBuilder.CreateIndex(
name: "IX_ImportAuditRuns_Status",
table: "ImportAuditRuns",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_ImportAuditRuns_TenantId",
table: "ImportAuditRuns",
column: "TenantId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ImportAuditIssues");
migrationBuilder.DropTable(
name: "ImportAuditRuns");
}
}
}