Skip to content

Commit

Permalink
Update ScriptRun/ScriptResult relationship.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jul 26, 2023
1 parent cf0fad5 commit 459c63f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Server/Data/AppDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AppDb : IdentityDbContext
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.ConfigureWarnings(x => x.Ignore(RelationalEventId.MultipleCollectionIncludeWarning));
//options.LogTo((message) => System.Diagnostics.Debug.Write(message));
options.LogTo((message) => System.Diagnostics.Debug.Write(message));
}

protected override void OnModelCreating(ModelBuilder builder)
Expand Down Expand Up @@ -157,6 +157,10 @@ protected override void OnModelCreating(ModelBuilder builder)
builder.Entity<ScriptRun>()
.HasMany(x => x.Devices)
.WithMany(x => x.ScriptRuns);
builder.Entity<ScriptRun>()
.HasMany(x => x.Results)
.WithOne(x => x.ScriptRun)
.IsRequired(false);

builder.Entity<ScriptResult>()
.Property(x => x.ErrorOutput)
Expand All @@ -173,6 +177,10 @@ protected override void OnModelCreating(ModelBuilder builder)
x => DeserializeStringArray(x, jsonOptions))
.Metadata
.SetValueComparer(_stringArrayComparer);
builder.Entity<ScriptResult>()
.HasOne(x => x.ScriptRun)
.WithMany(x => x.Results)
.IsRequired(false);

builder.Entity<Alert>()
.HasOne(x => x.User)
Expand Down
1 change: 1 addition & 0 deletions Shared/Models/ScriptResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ScriptResult
public int? ScheduleId { get; set; }
public Guid? SavedScriptId { get; set; }

public ScriptRun? ScriptRun { get; set; }
public int? ScriptRunId { get; set; }


Expand Down

0 comments on commit 459c63f

Please sign in to comment.