Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
/ ServerCommon Public archive

Commit

Permalink
Add error code for ScanOperationStates table (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
erdembayar authored Mar 22, 2024
1 parent dcad893 commit 3ea64a7
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/NuGet.Services.Validation/Entities/ScanOperationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public class ScanOperationState
/// </summary>
public string OperationId { get; set; }

/// <summary>
/// Operation error code.
/// </summary>
public string ErrorCode { get; set; }

/// <summary>
/// Any applicable operation details in text format.
/// </summary>
public string OperationDetails { get; set; }

/// <summary>
/// Used for optimistic concurrency when updating statuses.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class ValidationEntitiesContext : DbContext, IValidationEntitiesContext
private const string PackageCompatibilityIssuesTable = "PackageCompatibilityIssues";

private const string ScanOperationStatesTable = "ScanOperationStates";
private const string ScanOperationStatesPackageValidationKeyAttemptIndex = "IX_ScanOperationStates_PackageValidationKey_AttemptIndex";
private const string ScanOperationStatesPackageValidationKeyOperationTypeAttemptIndex = "IX_ScanOperationStates_PackageValidationKey_OperationType_AttemptIndex";
private const string ScanOperationStatesScanStateCreatedIndex = "IX_ScanOperationStates_ScanState_Created";

private const string PackageRevalidationPackageIdPackageVersionIndex = "IX_PackageRevalidations_PackageId_PackageNormalizedVersion";
Expand Down Expand Up @@ -625,7 +625,19 @@ private void RegisterScanningEntities(DbModelBuilder modelBuilder)
IndexAnnotation.AnnotationName,
new IndexAnnotation(new[]
{
new IndexAttribute(ScanOperationStatesPackageValidationKeyAttemptIndex, 0)
new IndexAttribute(ScanOperationStatesPackageValidationKeyOperationTypeAttemptIndex, 0)
{
IsUnique = true
}
}));

modelBuilder.Entity<ScanOperationState>()
.Property(s => s.OperationType)
.HasColumnAnnotation(
IndexAnnotation.AnnotationName,
new IndexAnnotation(new[]
{
new IndexAttribute(ScanOperationStatesPackageValidationKeyOperationTypeAttemptIndex, 1)
{
IsUnique = true
}
Expand All @@ -637,7 +649,7 @@ private void RegisterScanningEntities(DbModelBuilder modelBuilder)
IndexAnnotation.AnnotationName,
new IndexAnnotation(new[]
{
new IndexAttribute(ScanOperationStatesPackageValidationKeyAttemptIndex, 1)
new IndexAttribute(ScanOperationStatesPackageValidationKeyOperationTypeAttemptIndex, 2)
{
IsUnique = true
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace NuGet.Services.Validation
{
using System;
using System.Data.Entity.Migrations;

public partial class AddErrorCodeOperationDetails : DbMigration
{
public override void Up()
{
DropIndex("scan.ScanOperationStates", "IX_ScanOperationStates_PackageValidationKey_AttemptIndex");
AddColumn("scan.ScanOperationStates", "ErrorCode", c => c.String());
AddColumn("scan.ScanOperationStates", "OperationDetails", c => c.String());
CreateIndex("scan.ScanOperationStates", new[] { "PackageValidationKey", "OperationType", "AttemptIndex" }, unique: true, name: "IX_ScanOperationStates_PackageValidationKey_OperationType_AttemptIndex");
}

public override void Down()
{
DropIndex("scan.ScanOperationStates", "IX_ScanOperationStates_PackageValidationKey_OperationType_AttemptIndex");
DropColumn("scan.ScanOperationStates", "OperationDetails");
DropColumn("scan.ScanOperationStates", "ErrorCode");
CreateIndex("scan.ScanOperationStates", new[] { "PackageValidationKey", "AttemptIndex" }, unique: true, name: "IX_ScanOperationStates_PackageValidationKey_AttemptIndex");
}
}
}
Loading

0 comments on commit 3ea64a7

Please sign in to comment.