Skip to content

Commit a9e8ac2

Browse files
committed
Adding more
1 parent 7bd70f3 commit a9e8ac2

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

src/ServiceControl.Persistence.Sql.Core/DbContexts/ServiceControlDbContextBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ protected ServiceControlDbContextBase(DbContextOptions options) : base(options)
1717
public DbSet<SubscriptionEntity> Subscriptions { get; set; }
1818
public DbSet<QueueAddressEntity> QueueAddresses { get; set; }
1919
public DbSet<KnownEndpointEntity> KnownEndpoints { get; set; }
20+
public DbSet<CustomCheckEntity> CustomChecks { get; set; }
2021

2122
protected override void OnModelCreating(ModelBuilder modelBuilder)
2223
{
@@ -29,6 +30,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
2930
modelBuilder.ApplyConfiguration(new SubscriptionConfiguration());
3031
modelBuilder.ApplyConfiguration(new QueueAddressConfiguration());
3132
modelBuilder.ApplyConfiguration(new KnownEndpointConfiguration());
33+
modelBuilder.ApplyConfiguration(new CustomCheckConfiguration());
3234

3335
OnModelCreatingProvider(modelBuilder);
3436
}

src/ServiceControl.Persistence.Sql.Core/Implementation/CustomChecksDataStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public async Task<CheckStateChange> UpdateCustomCheckStatus(CustomCheckDetail de
5959
return status;
6060
}
6161

62-
public async Task<QueryResult<IList<CustomCheck>>> GetStats(PagingInfo paging, string status = null)
62+
public async Task<QueryResult<IList<CustomCheck>>> GetStats(PagingInfo paging, string? status = null)
6363
{
6464
using var scope = serviceProvider.CreateScope();
6565
var dbContext = scope.ServiceProvider.GetRequiredService<ServiceControlDbContextBase>();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace ServiceControl.Persistence.Sql.SqlServer.Migrations;
2+
3+
using Microsoft.EntityFrameworkCore.Migrations;
4+
5+
#nullable disable
6+
7+
/// <inheritdoc />
8+
public partial class AddCustomChecks : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.CreateTable(
14+
name: "CustomChecks",
15+
columns: table => new
16+
{
17+
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
18+
CustomCheckId = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
19+
Category = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
20+
Status = table.Column<int>(type: "int", nullable: false),
21+
ReportedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
22+
FailureReason = table.Column<string>(type: "nvarchar(max)", nullable: true),
23+
EndpointName = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
24+
HostId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
25+
Host = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false)
26+
},
27+
constraints: table =>
28+
{
29+
table.PrimaryKey("PK_CustomChecks", x => x.Id);
30+
});
31+
32+
migrationBuilder.CreateIndex(
33+
name: "IX_CustomChecks_Status",
34+
table: "CustomChecks",
35+
column: "Status");
36+
}
37+
38+
/// <inheritdoc />
39+
protected override void Down(MigrationBuilder migrationBuilder)
40+
{
41+
migrationBuilder.DropTable(
42+
name: "CustomChecks");
43+
}
44+
}

0 commit comments

Comments
 (0)