Skip to content

Commit 59f7083

Browse files
authored
Merge branch 'main' into features/offline-changes
2 parents 030a48a + 13e178d commit 59f7083

36 files changed

+2486
-81
lines changed

src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</PropertyGroup>
1010

1111
<PropertyGroup>
12-
<Authors>AStar Development, Jason Barden</Authors>
12+
<Authors>AStar Developement, Jason Barden</Authors>
1313
<Company>AStar Development</Company>
14-
<Copyright>AStar Development, 2025</Copyright>
14+
<Copyright>AStar Developement, 2025</Copyright>
1515
<Description>Defines the context and models for the FilesDb.</Description>
1616
<DocumentationFile>$(AssemblyName).xml</DocumentationFile>
1717
<GenerateDocumentationFile>true</GenerateDocumentationFile>

src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.xml

Lines changed: 3 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
7+
8+
internal sealed class DeletionStatusConfiguration : IComplexPropertyConfiguration<DeletionStatus>
9+
{
10+
public void Configure(ComplexPropertyBuilder<DeletionStatus> builder)
11+
{
12+
_ = builder
13+
.Property(deletionStatus => deletionStatus.HardDeletePending)
14+
.HasColumnName("HardDeletePending")
15+
.HasColumnType("datetimeoffset");
16+
17+
_ = builder
18+
.Property(deletionStatus => deletionStatus.SoftDeletePending)
19+
.HasColumnName("SoftDeletePending")
20+
.HasColumnType("datetimeoffset");
21+
22+
_ = builder
23+
.Property(deletionStatus => deletionStatus.SoftDeleted)
24+
.HasColumnName("SoftDeleted")
25+
.HasColumnType("datetimeoffset");
26+
}
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
7+
8+
internal sealed class DirectoryNameConfiguration : IComplexPropertyConfiguration<DirectoryName>
9+
{
10+
public void Configure(ComplexPropertyBuilder<DirectoryName> builder)
11+
=> builder.Property(directoryName => directoryName.Value)
12+
.HasColumnName("DirectoryName")
13+
.HasColumnType("nvarchar(256)");
14+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
7+
8+
/// <summary>
9+
/// </summary>
10+
public class EventConfiguration : IEntityTypeConfiguration<Event>
11+
{
12+
/// <inheritdoc />
13+
public void Configure(EntityTypeBuilder<Event> builder)
14+
{
15+
_ = builder
16+
.ToTable(nameof(Event), Constants.SchemaName)
17+
.HasKey(fileDetail => fileDetail.Id);
18+
19+
_ = builder.Property(fileDetail => fileDetail.FileName).HasMaxLength(256);
20+
_ = builder.Property(fileDetail => fileDetail.DirectoryName).HasMaxLength(256);
21+
_ = builder.Property(fileDetail => fileDetail.Handle).HasMaxLength(256);
22+
_ = builder.Property(fileDetail => fileDetail.UpdatedBy).HasMaxLength(30);
23+
24+
_ = builder.ComplexProperty(fileDetail => fileDetail.Type).Configure(new EventTypeConfiguration());
25+
}
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
7+
8+
internal sealed class EventTypeConfiguration : IComplexPropertyConfiguration<EventType>
9+
{
10+
public void Configure(ComplexPropertyBuilder<EventType> builder)
11+
{
12+
_ = builder.Property(eventType => eventType.Value).HasColumnName("EventType").IsRequired();
13+
_ = builder.Property(eventType => eventType.Name).HasColumnName("EventName").IsRequired();
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using AStar.Dev.Infrastructure.FilesDb.Models;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4+
5+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
6+
7+
/// <summary>
8+
/// </summary>
9+
public class FileClassificationConfiguration : IEntityTypeConfiguration<FileClassification>
10+
{
11+
/// <inheritdoc />
12+
public void Configure(EntityTypeBuilder<FileClassification> builder)
13+
{
14+
_ = builder
15+
.ToTable(nameof(FileClassification), Constants.SchemaName)
16+
.HasKey(fileClassification => fileClassification.Id);
17+
18+
_ = builder.HasMany<FileNamePart>();
19+
_ = builder.Property(fileClassification => fileClassification.Name).HasMaxLength(150);
20+
}
21+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
7+
8+
/// <summary>
9+
/// </summary>
10+
public class FileDetailConfiguration : IEntityTypeConfiguration<FileDetail>
11+
{
12+
/// <inheritdoc />
13+
public void Configure(EntityTypeBuilder<FileDetail> builder)
14+
{
15+
_ = builder.ToTable("FileDetail");
16+
17+
_ = builder.HasKey(file => file.Id);
18+
19+
_ = builder.Property(file => file.Id)
20+
.HasConversion(fileId => fileId.Value, fileId => new(fileId));
21+
22+
_ = builder.Ignore(fileDetail => fileDetail.FileName);
23+
_ = builder.Ignore(fileDetail => fileDetail.DirectoryName);
24+
_ = builder.Ignore(fileDetail => fileDetail.FullNameWithPath);
25+
26+
_ = builder.Property(file => file.FileHandle)
27+
.HasColumnType("nvarchar(256)")
28+
.HasConversion(fileHandle => fileHandle.Value, fileHandle => new(fileHandle));
29+
30+
_ = builder.ComplexProperty(fileDetail => fileDetail.ImageDetail)
31+
.Configure(new ImageDetailConfiguration());
32+
33+
_ = builder.ComplexProperty(fileDetail => fileDetail.DirectoryName)
34+
.Configure(new DirectoryNameConfiguration());
35+
36+
_ = builder.ComplexProperty(fileDetail => fileDetail.FileName)
37+
.Configure(new FileNameConfiguration());
38+
39+
_ = builder.ComplexProperty(fileDetail => fileDetail.DeletionStatus)
40+
.Configure(new DeletionStatusConfiguration());
41+
42+
_ = builder.HasIndex(fileDetail => fileDetail.FileHandle).IsUnique();
43+
_ = builder.HasIndex(fileDetail => fileDetail.FileSize);
44+
45+
// Composite index to optimize duplicate images search (partial optimization)
46+
// Note: ImageHeight and ImageWidth can't be indexed directly as they're complex properties
47+
_ = builder.HasIndex(fileDetail => new { fileDetail.IsImage, fileDetail.FileSize })
48+
.HasDatabaseName("IX_FileDetail_DuplicateImages");
49+
}
50+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using AStar.Dev.Infrastructure.Data.Configurations;
2+
using AStar.Dev.Infrastructure.FilesDb.Models;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
5+
6+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
7+
8+
internal sealed class FileNameConfiguration : IComplexPropertyConfiguration<FileName>
9+
{
10+
public void Configure(ComplexPropertyBuilder<FileName> builder)
11+
=> builder.Property(fileName => fileName.Value)
12+
.HasColumnName("FileName")
13+
.HasColumnType("nvarchar(256)");
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using AStar.Dev.Infrastructure.FilesDb.Models;
2+
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4+
5+
namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations;
6+
7+
/// <summary>
8+
/// </summary>
9+
public class FileNamePartConfiguration : IEntityTypeConfiguration<FileNamePart>
10+
{
11+
/// <inheritdoc />
12+
public void Configure(EntityTypeBuilder<FileNamePart> builder)
13+
{
14+
_ = builder
15+
.ToTable(nameof(FileNamePart), Constants.SchemaName)
16+
.HasKey(fileNamePart => fileNamePart.Id);
17+
18+
_ = builder.Property(fileNamePart => fileNamePart.Text).HasMaxLength(150);
19+
}
20+
}

0 commit comments

Comments
 (0)