line-gestao-api/Migrations/20260309120000_AddMveAuditH...

161 lines
8.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace line_gestao_api.Migrations
{
/// <inheritdoc />
public partial class AddMveAuditHistoryAndAparelhoFabricante : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Fabricante",
table: "Aparelhos",
type: "character varying(120)",
maxLength: 120,
nullable: true);
migrationBuilder.CreateTable(
name: "MveAuditRuns",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
FileName = table.Column<string>(type: "character varying(260)", maxLength: 260, nullable: true),
FileHashSha256 = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
FileEncoding = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true),
Status = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
TotalSystemLines = table.Column<int>(type: "integer", nullable: false),
TotalReportLines = table.Column<int>(type: "integer", nullable: false),
TotalConciliated = table.Column<int>(type: "integer", nullable: false),
TotalStatusDivergences = table.Column<int>(type: "integer", nullable: false),
TotalDataDivergences = table.Column<int>(type: "integer", nullable: false),
TotalOnlyInSystem = table.Column<int>(type: "integer", nullable: false),
TotalOnlyInReport = table.Column<int>(type: "integer", nullable: false),
TotalDuplicateReportLines = table.Column<int>(type: "integer", nullable: false),
TotalDuplicateSystemLines = table.Column<int>(type: "integer", nullable: false),
TotalInvalidRows = table.Column<int>(type: "integer", nullable: false),
TotalUnknownStatuses = table.Column<int>(type: "integer", nullable: false),
TotalSyncableIssues = table.Column<int>(type: "integer", nullable: false),
AppliedIssuesCount = table.Column<int>(type: "integer", nullable: false),
AppliedLinesCount = table.Column<int>(type: "integer", nullable: false),
AppliedFieldsCount = table.Column<int>(type: "integer", nullable: false),
ImportedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
AppliedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
AppliedByUserId = table.Column<Guid>(type: "uuid", nullable: true),
AppliedByUserName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
AppliedByUserEmail = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MveAuditRuns", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MveAuditIssues",
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),
SourceRowNumber = table.Column<int>(type: "integer", nullable: true),
NumeroLinha = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
MobileLineId = table.Column<Guid>(type: "uuid", nullable: true),
SystemItem = table.Column<int>(type: "integer", nullable: true),
IssueType = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: false),
Situation = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: false),
Severity = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
Syncable = table.Column<bool>(type: "boolean", nullable: false),
Applied = table.Column<bool>(type: "boolean", nullable: false),
AppliedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
ActionSuggestion = table.Column<string>(type: "character varying(160)", maxLength: 160, nullable: true),
Notes = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
SystemStatus = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: true),
ReportStatus = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: true),
SystemPlan = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
ReportPlan = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
SystemSnapshotJson = table.Column<string>(type: "jsonb", nullable: false),
ReportSnapshotJson = table.Column<string>(type: "jsonb", nullable: false),
DifferencesJson = table.Column<string>(type: "jsonb", nullable: false),
CreatedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MveAuditIssues", x => x.Id);
table.ForeignKey(
name: "FK_MveAuditIssues_MveAuditRuns_AuditRunId",
column: x => x.AuditRunId,
principalTable: "MveAuditRuns",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Aparelhos_TenantId_Fabricante",
table: "Aparelhos",
columns: new[] { "TenantId", "Fabricante" });
migrationBuilder.CreateIndex(
name: "IX_MveAuditIssues_AuditRunId",
table: "MveAuditIssues",
column: "AuditRunId");
migrationBuilder.CreateIndex(
name: "IX_MveAuditIssues_IssueType",
table: "MveAuditIssues",
column: "IssueType");
migrationBuilder.CreateIndex(
name: "IX_MveAuditIssues_NumeroLinha",
table: "MveAuditIssues",
column: "NumeroLinha");
migrationBuilder.CreateIndex(
name: "IX_MveAuditIssues_Syncable",
table: "MveAuditIssues",
column: "Syncable");
migrationBuilder.CreateIndex(
name: "IX_MveAuditIssues_TenantId",
table: "MveAuditIssues",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_MveAuditRuns_ImportedAtUtc",
table: "MveAuditRuns",
column: "ImportedAtUtc");
migrationBuilder.CreateIndex(
name: "IX_MveAuditRuns_Status",
table: "MveAuditRuns",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_MveAuditRuns_TenantId",
table: "MveAuditRuns",
column: "TenantId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MveAuditIssues");
migrationBuilder.DropTable(
name: "MveAuditRuns");
migrationBuilder.DropIndex(
name: "IX_Aparelhos_TenantId_Fabricante",
table: "Aparelhos");
migrationBuilder.DropColumn(
name: "Fabricante",
table: "Aparelhos");
}
}
}