using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace line_gestao_api.Migrations { /// public partial class AddMveAuditHistoryAndAparelhoFabricante : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "Fabricante", table: "Aparelhos", type: "character varying(120)", maxLength: 120, nullable: true); migrationBuilder.CreateTable( name: "MveAuditRuns", columns: table => new { Id = table.Column(type: "uuid", nullable: false), TenantId = table.Column(type: "uuid", nullable: false), FileName = table.Column(type: "character varying(260)", maxLength: 260, nullable: true), FileHashSha256 = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), FileEncoding = table.Column(type: "character varying(40)", maxLength: 40, nullable: true), Status = table.Column(type: "character varying(40)", maxLength: 40, nullable: false), TotalSystemLines = table.Column(type: "integer", nullable: false), TotalReportLines = table.Column(type: "integer", nullable: false), TotalConciliated = table.Column(type: "integer", nullable: false), TotalStatusDivergences = table.Column(type: "integer", nullable: false), TotalDataDivergences = table.Column(type: "integer", nullable: false), TotalOnlyInSystem = table.Column(type: "integer", nullable: false), TotalOnlyInReport = table.Column(type: "integer", nullable: false), TotalDuplicateReportLines = table.Column(type: "integer", nullable: false), TotalDuplicateSystemLines = table.Column(type: "integer", nullable: false), TotalInvalidRows = table.Column(type: "integer", nullable: false), TotalUnknownStatuses = table.Column(type: "integer", nullable: false), TotalSyncableIssues = table.Column(type: "integer", nullable: false), AppliedIssuesCount = table.Column(type: "integer", nullable: false), AppliedLinesCount = table.Column(type: "integer", nullable: false), AppliedFieldsCount = table.Column(type: "integer", nullable: false), ImportedAtUtc = table.Column(type: "timestamp with time zone", nullable: false), AppliedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), AppliedByUserId = table.Column(type: "uuid", nullable: true), AppliedByUserName = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), AppliedByUserEmail = table.Column(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(type: "uuid", nullable: false), TenantId = table.Column(type: "uuid", nullable: false), AuditRunId = table.Column(type: "uuid", nullable: false), SourceRowNumber = table.Column(type: "integer", nullable: true), NumeroLinha = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), MobileLineId = table.Column(type: "uuid", nullable: true), SystemItem = table.Column(type: "integer", nullable: true), IssueType = table.Column(type: "character varying(60)", maxLength: 60, nullable: false), Situation = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), Severity = table.Column(type: "character varying(40)", maxLength: 40, nullable: false), Syncable = table.Column(type: "boolean", nullable: false), Applied = table.Column(type: "boolean", nullable: false), AppliedAtUtc = table.Column(type: "timestamp with time zone", nullable: true), ActionSuggestion = table.Column(type: "character varying(160)", maxLength: 160, nullable: true), Notes = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), SystemStatus = table.Column(type: "character varying(120)", maxLength: 120, nullable: true), ReportStatus = table.Column(type: "character varying(120)", maxLength: 120, nullable: true), SystemPlan = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), ReportPlan = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), SystemSnapshotJson = table.Column(type: "jsonb", nullable: false), ReportSnapshotJson = table.Column(type: "jsonb", nullable: false), DifferencesJson = table.Column(type: "jsonb", nullable: false), CreatedAtUtc = table.Column(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"); } /// 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"); } } }