Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 08175ef

Browse files
committed
Merge branch 'feat/AddingDiscoveryFunction' of https://github.com/NHSDigital/dtos-service-layer into feat/AddingDiscoveryFunction
2 parents bc24b70 + a4fb3bc commit 08175ef

File tree

6 files changed

+200
-1
lines changed

6 files changed

+200
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using Microsoft.EntityFrameworkCore.Design;
3+
using ServiceLayer.Mesh.Data;
4+
5+
namespace ParticipantManager.API.Data;
6+
7+
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ServiceLayerDbContext>
8+
{
9+
public ServiceLayerDbContext CreateDbContext(string[] args)
10+
{
11+
var connectionString = Environment.GetEnvironmentVariable("DatabaseConnectionString");
12+
if (string.IsNullOrEmpty(connectionString))
13+
{
14+
throw new InvalidOperationException("Connection string 'DatabaseConnectionString' is not configured.");
15+
}
16+
17+
var optionsBuilder = new DbContextOptionsBuilder<ServiceLayerDbContext>();
18+
optionsBuilder.UseSqlServer(connectionString);
19+
20+
return new ServiceLayerDbContext(optionsBuilder.Options);
21+
}
22+
}

src/ServiceLayer.Mesh/Migrations/20250512113115_InitialCreate.Designer.cs

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace ServiceLayer.Mesh.Migrations
7+
{
8+
/// <inheritdoc />
9+
public partial class InitialCreate : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
migrationBuilder.CreateTable(
15+
name: "MeshFiles",
16+
columns: table => new
17+
{
18+
FileId = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
19+
FileType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
20+
MailboxId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
21+
Status = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
22+
BlobPath = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true),
23+
FirstSeenUtc = table.Column<DateTime>(type: "datetime2", nullable: false),
24+
LastUpdatedUtc = table.Column<DateTime>(type: "datetime2", nullable: false)
25+
},
26+
constraints: table =>
27+
{
28+
table.PrimaryKey("PK_MeshFiles", x => x.FileId);
29+
});
30+
}
31+
32+
/// <inheritdoc />
33+
protected override void Down(MigrationBuilder migrationBuilder)
34+
{
35+
migrationBuilder.DropTable(
36+
name: "MeshFiles");
37+
}
38+
}
39+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// <auto-generated />
2+
using System;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Infrastructure;
5+
using Microsoft.EntityFrameworkCore.Metadata;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
using ServiceLayer.Mesh.Data;
8+
9+
#nullable disable
10+
11+
namespace ServiceLayer.Mesh.Migrations
12+
{
13+
[DbContext(typeof(ServiceLayerDbContext))]
14+
partial class ServiceLayerDbContextModelSnapshot : ModelSnapshot
15+
{
16+
protected override void BuildModel(ModelBuilder modelBuilder)
17+
{
18+
#pragma warning disable 612, 618
19+
modelBuilder
20+
.HasAnnotation("ProductVersion", "9.0.1")
21+
.HasAnnotation("Relational:MaxIdentifierLength", 128);
22+
23+
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
24+
25+
modelBuilder.Entity("ServiceLayer.Mesh.Models.MeshFile", b =>
26+
{
27+
b.Property<string>("FileId")
28+
.HasMaxLength(255)
29+
.HasColumnType("nvarchar(255)");
30+
31+
b.Property<string>("BlobPath")
32+
.HasMaxLength(1024)
33+
.HasColumnType("nvarchar(1024)");
34+
35+
b.Property<string>("FileType")
36+
.IsRequired()
37+
.HasMaxLength(50)
38+
.HasColumnType("nvarchar(50)");
39+
40+
b.Property<DateTime>("FirstSeenUtc")
41+
.HasColumnType("datetime2");
42+
43+
b.Property<DateTime>("LastUpdatedUtc")
44+
.HasColumnType("datetime2");
45+
46+
b.Property<string>("MailboxId")
47+
.IsRequired()
48+
.HasMaxLength(50)
49+
.HasColumnType("nvarchar(50)");
50+
51+
b.Property<string>("Status")
52+
.IsRequired()
53+
.HasMaxLength(20)
54+
.HasColumnType("nvarchar(20)");
55+
56+
b.HasKey("FileId");
57+
58+
b.ToTable("MeshFiles");
59+
});
60+
#pragma warning restore 612, 618
61+
}
62+
}
63+
}

src/ServiceLayer.Mesh/Models/MeshFile.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
using System.ComponentModel.DataAnnotations;
12
using Microsoft.EntityFrameworkCore.Metadata.Internal;
23

34
namespace ServiceLayer.Mesh.Models;
45

56
public class MeshFile
67
{
8+
[MaxLength(255)]
79
public required string FileId { get; set; }
10+
[MaxLength(50)]
811
public required MeshFileType FileType { get; set; }
12+
[MaxLength(50)]
913
public required string MailboxId { get; set; }
14+
[MaxLength(20)]
1015
public required MeshFileStatus Status { get; set; }
16+
[MaxLength(1024)]
1117
public string? BlobPath { get; set; }
1218
public DateTime FirstSeenUtc { get; set; }
1319
public DateTime LastUpdatedUtc { get; set; }

src/ServiceLayer.Mesh/ServiceLayer.Mesh.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
1919
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
2020
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
21-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1" />
21+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1">
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
<PrivateAssets>all</PrivateAssets>
24+
</PackageReference>
2225
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
2326
</ItemGroup>
2427
<ItemGroup>

0 commit comments

Comments
 (0)