Skip to content

Commit

Permalink
ensure the harmony table names are consistent now that we have a hard…
Browse files Browse the repository at this point in the history
…coded sql query
  • Loading branch information
hahn-kev committed Aug 26, 2024
1 parent 64c1baf commit 8317068
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/SIL.Harmony/Db/EntityConfig/ChangeEntityConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ChangeEntityConfig(JsonSerializerOptions jsonSerializerOptions) : I
{
public void Configure(EntityTypeBuilder<ChangeEntity<IChange>> builder)
{
builder.ToTable("ChangeEntities");
builder.HasKey(c => new { c.CommitId, c.Index });
builder.Property(c => c.Change)
.HasColumnType("jsonb")
Expand All @@ -25,4 +26,4 @@ private IChange DeserializeChange(string json)
return JsonSerializer.Deserialize<IChange>(json, jsonSerializerOptions) ??
throw new SerializationException("Could not deserialize Change: " + json);
}
}
}
3 changes: 2 additions & 1 deletion src/SIL.Harmony/Db/EntityConfig/CommitEntityConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class CommitEntityConfig : IEntityTypeConfiguration<Commit>
{
public void Configure(EntityTypeBuilder<Commit> builder)
{
builder.ToTable("Commits");
builder.HasKey(c => c.Id);
builder.ComplexProperty(c => c.HybridDateTime,
hybridEntity =>
Expand All @@ -31,4 +32,4 @@ public void Configure(EntityTypeBuilder<Commit> builder)
.WithOne()
.HasForeignKey(c => c.CommitId);
}
}
}
3 changes: 2 additions & 1 deletion src/SIL.Harmony/Db/EntityConfig/SnapshotEntityConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class SnapshotEntityConfig(JsonSerializerOptions jsonSerializerOptions) :
{
public void Configure(EntityTypeBuilder<ObjectSnapshot> builder)
{
builder.ToTable("Snapshots");
builder.HasKey(s => s.Id);
builder.HasIndex(s => new { s.CommitId, s.EntityId }).IsUnique();
builder
Expand All @@ -29,4 +30,4 @@ private IObjectBase DeserializeObject(string json)
return JsonSerializer.Deserialize<IObjectBase>(json, jsonSerializerOptions) ??
throw new SerializationException($"Could not deserialize Entry: {json}");
}
}
}

0 comments on commit 8317068

Please sign in to comment.