From 230ee7aa0411b1374ead70aa3df9f78e57ae27da Mon Sep 17 00:00:00 2001 From: Jason Barden Date: Mon, 22 Sep 2025 21:31:11 +0100 Subject: [PATCH 1/2] Add CreatedDate, refactor ImageDetail Fix duplication in Configurations Remove the dummy projects --- .../AStar.Dev.Infrastructure.FilesDb.csproj | 4 + .../AStar.Dev.Infrastructure.FilesDb.xml | 178 ++------ .../DeletionStatusConfiguration.cs | 30 -- .../DirectoryNameConfiguration.cs | 13 - .../Configurations/EventConfiguration.cs | 25 - .../Configurations/EventTypeConfiguration.cs | 14 - .../FileClassificationConfiguration.cs | 23 - .../Configurations/FileDetailConfiguration.cs | 43 -- .../Configurations/FileNameConfiguration.cs | 13 - .../FileNamePartConfiguration.cs | 20 - .../ImageDetailConfiguration.cs | 18 - .../ComplexPropertyBuilderConfiguration.cs | 2 +- .../DeletionStatusConfiguration.cs | 11 +- .../DirectoryNameConfiguration.cs | 3 +- .../Data/Configurations/EventConfiguration.cs | 3 +- .../Configurations/EventTypeConfiguration.cs | 1 - .../FileAccessDetailConfiguration.cs | 2 +- .../FileClassificationConfiguration.cs | 4 +- .../Configurations/FileDetailConfiguration.cs | 9 +- .../Configurations/FileNameConfiguration.cs | 1 - .../IComplexPropertyConfiguration.cs | 2 +- .../ModelToIgnoreConfiguration.cs | 2 +- .../TagToIgnoreConfiguration.cs | 2 +- ...20250715194331_InitialCreation.Designer.cs | 0 .../20250715194331_InitialCreation.cs | 0 .../20250725184934_RecreateAgain.Designer.cs | 343 -------------- .../20250725184934_RecreateAgain.cs | 218 --------- .../20250725190252_RecreateAgain2.Designer.cs | 351 -------------- .../20250725190252_RecreateAgain2.cs | 26 -- ...35_UpdateFileNameConfiguration.Designer.cs | 353 -------------- ...50729201535_UpdateFileNameConfiguration.cs | 24 - ...729202510_AddFileDetailIndexes.Designer.cs | 353 -------------- .../20250729202510_AddFileDetailIndexes.cs | 21 - ...163238_AddDuplicateImagesIndex.Designer.cs | 359 --------------- .../20250808163238_AddDuplicateImagesIndex.cs | 51 --- ...20250919204057_InitialCreation.Designer.cs | 430 ------------------ ...1728_RestructureDeletionAndImageDetails.cs | 244 ---------- ...250922202225_RecreateDatabase.Designer.cs} | 62 +-- ....cs => 20250922202225_RecreateDatabase.cs} | 87 +++- .../Migrations/FilesContextModelSnapshot.cs | 58 +-- .../Models/FileDetail.cs | 7 +- .../Models/ImageDetail.cs | 20 +- 42 files changed, 183 insertions(+), 3247 deletions(-) delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/DeletionStatusConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/DirectoryNameConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventTypeConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileClassificationConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileDetailConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNameConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNamePartConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Configurations/ImageDetailConfiguration.cs rename src/AStar.Dev.Infrastructure.FilesDb/{ => Data}/Configurations/ComplexPropertyBuilderConfiguration.cs (90%) rename src/AStar.Dev.Infrastructure.FilesDb/{ => Data}/Configurations/FileAccessDetailConfiguration.cs (89%) rename src/AStar.Dev.Infrastructure.FilesDb/{ => Data}/Configurations/IComplexPropertyConfiguration.cs (84%) rename src/AStar.Dev.Infrastructure.FilesDb/{ => Data}/Configurations/ModelToIgnoreConfiguration.cs (90%) rename src/AStar.Dev.Infrastructure.FilesDb/{ => Data}/Configurations/TagToIgnoreConfiguration.cs (89%) delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250715194331_InitialCreation.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250715194331_InitialCreation.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.Designer.cs delete mode 100644 src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.cs rename src/AStar.Dev.Infrastructure.FilesDb/Migrations/{20250919211728_RestructureDeletionAndImageDetails.Designer.cs => 20250922202225_RecreateDatabase.Designer.cs} (90%) rename src/AStar.Dev.Infrastructure.FilesDb/Migrations/{20250919204057_InitialCreation.cs => 20250922202225_RecreateDatabase.cs} (79%) diff --git a/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj b/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj index f549fb5..9732a58 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj +++ b/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj @@ -61,6 +61,10 @@ + + + + True 1701;1702; diff --git a/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.xml b/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.xml index 976b03d..d6b6a65 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.xml +++ b/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.xml @@ -4,11 +4,19 @@ AStar.Dev.Infrastructure.FilesDb - + + + + + + + + + - + @@ -16,100 +24,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + @@ -245,6 +217,9 @@ Gets or sets the DuplicatesDetails loaded from the configured view in the database + + + The overridden OnModelCreating method @@ -287,88 +262,16 @@ The original list of files for further filtering. - - - - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -755,6 +658,11 @@ Gets or sets the file size. I know, shocking... + + + Gets or sets the file Creation Date. I know, shocking... + + Gets or sets whether the file is of a supported image type @@ -939,15 +847,7 @@ - - - - - - - - - + diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/DeletionStatusConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/DeletionStatusConfiguration.cs deleted file mode 100644 index 22f1de4..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/DeletionStatusConfiguration.cs +++ /dev/null @@ -1,30 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -internal sealed class DeletionStatusConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - _ = builder - .ToTable(nameof(DeletionStatus), Constants.SchemaName) - .HasKey(deletionStatus => deletionStatus.Id); - - _ = builder - .Property(deletionStatus => deletionStatus.HardDeletePending) - .HasColumnName("HardDeletePending") - .HasColumnType("datetimeoffset"); - - _ = builder - .Property(deletionStatus => deletionStatus.SoftDeletePending) - .HasColumnName("SoftDeletePending") - .HasColumnType("datetimeoffset"); - - _ = builder - .Property(deletionStatus => deletionStatus.SoftDeleted) - .HasColumnName("SoftDeleted") - .HasColumnType("datetimeoffset"); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/DirectoryNameConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/DirectoryNameConfiguration.cs deleted file mode 100644 index 18c6f0f..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/DirectoryNameConfiguration.cs +++ /dev/null @@ -1,13 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -internal sealed class DirectoryNameConfiguration : IComplexPropertyConfiguration -{ - public void Configure(ComplexPropertyBuilder builder) - => builder.Property(directoryName => directoryName.Value) - .HasColumnName("DirectoryName") - .HasColumnType("nvarchar(256)"); -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventConfiguration.cs deleted file mode 100644 index b2f2ac8..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventConfiguration.cs +++ /dev/null @@ -1,25 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -/// -/// -public class EventConfiguration : IEntityTypeConfiguration -{ - /// - public void Configure(EntityTypeBuilder builder) - { - _ = builder - .ToTable(nameof(Event), Constants.SchemaName) - .HasKey(fileDetail => fileDetail.Id); - - _ = builder.Property(fileDetail => fileDetail.FileName).HasMaxLength(256); - _ = builder.Property(fileDetail => fileDetail.DirectoryName).HasMaxLength(256); - _ = builder.Property(fileDetail => fileDetail.Handle).HasMaxLength(256); - _ = builder.Property(fileDetail => fileDetail.UpdatedBy).HasMaxLength(30); - - _ = builder.ComplexProperty(fileDetail => fileDetail.Type).Configure(new EventTypeConfiguration()); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventTypeConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventTypeConfiguration.cs deleted file mode 100644 index 2fbf538..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/EventTypeConfiguration.cs +++ /dev/null @@ -1,14 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -internal sealed class EventTypeConfiguration : IComplexPropertyConfiguration -{ - public void Configure(ComplexPropertyBuilder builder) - { - _ = builder.Property(eventType => eventType.Value).HasColumnName("EventType").IsRequired(); - _ = builder.Property(eventType => eventType.Name).HasColumnName("EventName").IsRequired(); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileClassificationConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileClassificationConfiguration.cs deleted file mode 100644 index 4ae2bab..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileClassificationConfiguration.cs +++ /dev/null @@ -1,23 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -/// -/// -public class FileClassificationConfiguration : IEntityTypeConfiguration -{ - /// - public void Configure(EntityTypeBuilder builder) - { - _ = builder - .ToTable(nameof(FileClassification), Constants.SchemaName) - .HasKey(fileClassification => fileClassification.Id); - - _ = builder.HasIndex(fileClassification => fileClassification.Name).IsUnique(); - - //_ = builder.HasMany(); - _ = builder.Property(fileClassification => fileClassification.Name).HasMaxLength(150); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileDetailConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileDetailConfiguration.cs deleted file mode 100644 index 38d5856..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileDetailConfiguration.cs +++ /dev/null @@ -1,43 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -/// -/// -public class FileDetailConfiguration : IEntityTypeConfiguration -{ - /// - public void Configure(EntityTypeBuilder builder) - { - _ = builder.ToTable("FileDetail"); - - _ = builder.HasKey(file => file.Id); - - _ = builder.Property(file => file.Id) - .HasConversion(fileId => fileId.Value, fileId => new(fileId)); - - _ = builder.Ignore(fileDetail => fileDetail.FileName); - _ = builder.Ignore(fileDetail => fileDetail.DirectoryName); - _ = builder.Ignore(fileDetail => fileDetail.FullNameWithPath); - - _ = builder.Property(file => file.FileHandle) - .HasColumnType("nvarchar(256)") - .HasConversion(fileHandle => fileHandle.Value, fileHandle => new(fileHandle)); - - _ = builder.ComplexProperty(fileDetail => fileDetail.DirectoryName) - .Configure(new DirectoryNameConfiguration()); - - _ = builder.ComplexProperty(fileDetail => fileDetail.FileName) - .Configure(new FileNameConfiguration()); - - _ = builder.HasIndex(fileDetail => fileDetail.FileHandle).IsUnique(); - _ = builder.HasIndex(fileDetail => fileDetail.FileSize); - - // Composite index to optimize duplicate images search (partial optimization) - // Note: ImageHeight and ImageWidth can't be indexed directly as they're complex properties - _ = builder.HasIndex(fileDetail => new { fileDetail.IsImage, fileDetail.FileSize }) - .HasDatabaseName("IX_FileDetail_DuplicateImages"); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNameConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNameConfiguration.cs deleted file mode 100644 index e93dfe8..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNameConfiguration.cs +++ /dev/null @@ -1,13 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -internal sealed class FileNameConfiguration : IComplexPropertyConfiguration -{ - public void Configure(ComplexPropertyBuilder builder) - => builder.Property(fileName => fileName.Value) - .HasColumnName("FileName") - .HasColumnType("nvarchar(256)"); -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNamePartConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNamePartConfiguration.cs deleted file mode 100644 index 2b5a981..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileNamePartConfiguration.cs +++ /dev/null @@ -1,20 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -/// -/// -public class FileNamePartConfiguration : IEntityTypeConfiguration -{ - /// - public void Configure(EntityTypeBuilder builder) - { - _ = builder - .ToTable(nameof(FileNamePart), Constants.SchemaName) - .HasKey(fileNamePart => fileNamePart.Id); - - _ = builder.Property(fileNamePart => fileNamePart.Text).HasMaxLength(150); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ImageDetailConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ImageDetailConfiguration.cs deleted file mode 100644 index 98fc49c..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ImageDetailConfiguration.cs +++ /dev/null @@ -1,18 +0,0 @@ -using AStar.Dev.Infrastructure.FilesDb.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; - -internal sealed class ImageDetailConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - _ = builder - .ToTable(nameof(ImageDetail), Constants.SchemaName) - .HasKey(imageDetail => imageDetail.Id); - - _ = builder.Property(image => image.Width).HasColumnName("ImageWidth"); - _ = builder.Property(image => image.Height).HasColumnName("ImageHeight"); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ComplexPropertyBuilderConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ComplexPropertyBuilderConfiguration.cs similarity index 90% rename from src/AStar.Dev.Infrastructure.FilesDb/Configurations/ComplexPropertyBuilderConfiguration.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ComplexPropertyBuilderConfiguration.cs index 2453720..47678d6 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ComplexPropertyBuilderConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ComplexPropertyBuilderConfiguration.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; +namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations; /// /// diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DeletionStatusConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DeletionStatusConfiguration.cs index 6c0fe09..bbae765 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DeletionStatusConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DeletionStatusConfiguration.cs @@ -1,14 +1,17 @@ -using AStar.Dev.Infrastructure.Data.Configurations; -using AStar.Dev.Infrastructure.FilesDb.Models; +using AStar.Dev.Infrastructure.FilesDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations; -internal sealed class DeletionStatusConfiguration : IComplexPropertyConfiguration +internal sealed class DeletionStatusConfiguration : IEntityTypeConfiguration { - public void Configure(ComplexPropertyBuilder builder) + public void Configure(EntityTypeBuilder builder) { + _ = builder + .ToTable(nameof(DeletionStatus), Constants.SchemaName) + .HasKey(deletionStatus => deletionStatus.Id); + _ = builder .Property(deletionStatus => deletionStatus.HardDeletePending) .HasColumnName("HardDeletePending") diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DirectoryNameConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DirectoryNameConfiguration.cs index 8e7d470..32548e8 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DirectoryNameConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/DirectoryNameConfiguration.cs @@ -1,5 +1,4 @@ -using AStar.Dev.Infrastructure.Data.Configurations; -using AStar.Dev.Infrastructure.FilesDb.Models; +using AStar.Dev.Infrastructure.FilesDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventConfiguration.cs index d5f8839..1f05f60 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventConfiguration.cs @@ -1,5 +1,4 @@ -using AStar.Dev.Infrastructure.Data.Configurations; -using AStar.Dev.Infrastructure.FilesDb.Models; +using AStar.Dev.Infrastructure.FilesDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventTypeConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventTypeConfiguration.cs index 5f7defd..639eac8 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventTypeConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/EventTypeConfiguration.cs @@ -1,4 +1,3 @@ -using AStar.Dev.Infrastructure.Data.Configurations; using AStar.Dev.Infrastructure.FilesDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileAccessDetailConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileAccessDetailConfiguration.cs similarity index 89% rename from src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileAccessDetailConfiguration.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileAccessDetailConfiguration.cs index 22ac621..b397bb7 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/FileAccessDetailConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileAccessDetailConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; +namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations; /// /// diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileClassificationConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileClassificationConfiguration.cs index 7cc7943..de86773 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileClassificationConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileClassificationConfiguration.cs @@ -15,7 +15,9 @@ public void Configure(EntityTypeBuilder builder) .ToTable(nameof(FileClassification), Constants.SchemaName) .HasKey(fileClassification => fileClassification.Id); - _ = builder.HasMany(); + _ = builder.HasIndex(fileClassification => fileClassification.Name).IsUnique(); + + //_ = builder.HasMany(); _ = builder.Property(fileClassification => fileClassification.Name).HasMaxLength(150); } } \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileDetailConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileDetailConfiguration.cs index 8817e16..786c100 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileDetailConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileDetailConfiguration.cs @@ -1,4 +1,3 @@ -using AStar.Dev.Infrastructure.Data.Configurations; using AStar.Dev.Infrastructure.FilesDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -22,22 +21,20 @@ public void Configure(EntityTypeBuilder builder) _ = builder.Ignore(fileDetail => fileDetail.FileName); _ = builder.Ignore(fileDetail => fileDetail.DirectoryName); _ = builder.Ignore(fileDetail => fileDetail.FullNameWithPath); + _ = builder.Ignore(fileDetail => fileDetail.ImageDetail); _ = builder.Property(file => file.FileHandle) .HasColumnType("nvarchar(256)") .HasConversion(fileHandle => fileHandle.Value, fileHandle => new(fileHandle)); - _ = builder.ComplexProperty(fileDetail => fileDetail.ImageDetail) - .Configure(new ImageDetailConfiguration()); - _ = builder.ComplexProperty(fileDetail => fileDetail.DirectoryName) .Configure(new DirectoryNameConfiguration()); _ = builder.ComplexProperty(fileDetail => fileDetail.FileName) .Configure(new FileNameConfiguration()); - _ = builder.ComplexProperty(fileDetail => fileDetail.DeletionStatus) - .Configure(new DeletionStatusConfiguration()); + _ = builder.ComplexProperty(fileDetail => fileDetail.ImageDetail) + .Configure(new ImageDetailConfiguration()); _ = builder.HasIndex(fileDetail => fileDetail.FileHandle).IsUnique(); _ = builder.HasIndex(fileDetail => fileDetail.FileSize); diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileNameConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileNameConfiguration.cs index a8afc7e..20cd330 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileNameConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/FileNameConfiguration.cs @@ -1,4 +1,3 @@ -using AStar.Dev.Infrastructure.Data.Configurations; using AStar.Dev.Infrastructure.FilesDb.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/IComplexPropertyConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/IComplexPropertyConfiguration.cs similarity index 84% rename from src/AStar.Dev.Infrastructure.FilesDb/Configurations/IComplexPropertyConfiguration.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/IComplexPropertyConfiguration.cs index 84833f6..92bfb50 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/IComplexPropertyConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/IComplexPropertyConfiguration.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; +namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations; /// /// diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ModelToIgnoreConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ModelToIgnoreConfiguration.cs similarity index 90% rename from src/AStar.Dev.Infrastructure.FilesDb/Configurations/ModelToIgnoreConfiguration.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ModelToIgnoreConfiguration.cs index 0fe0248..8a86edb 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/ModelToIgnoreConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/ModelToIgnoreConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; +namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations; /// /// diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/TagToIgnoreConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/TagToIgnoreConfiguration.cs similarity index 89% rename from src/AStar.Dev.Infrastructure.FilesDb/Configurations/TagToIgnoreConfiguration.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/TagToIgnoreConfiguration.cs index 5e25176..7cbc5c3 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Configurations/TagToIgnoreConfiguration.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Data/Configurations/TagToIgnoreConfiguration.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -namespace AStar.Dev.Infrastructure.FilesDb.Configurations; +namespace AStar.Dev.Infrastructure.FilesDb.Data.Configurations; /// /// diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250715194331_InitialCreation.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250715194331_InitialCreation.Designer.cs deleted file mode 100644 index e69de29..0000000 diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250715194331_InitialCreation.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250715194331_InitialCreation.cs deleted file mode 100644 index e69de29..0000000 diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.Designer.cs deleted file mode 100644 index 1d12a66..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.Designer.cs +++ /dev/null @@ -1,343 +0,0 @@ -// - -using System.Collections.Generic; -using AStar.Dev.Infrastructure.FilesDb.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations -{ - [DbContext(typeof(FilesContext))] - [Migration("20250725184934_RecreateAgain")] - partial class RecreateAgain - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("files") - .UseCollation("SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("ProductVersion", "9.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.DuplicateDetail", b => - { - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileHandle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("HardDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("ImageHeight") - .HasColumnType("int"); - - b.Property("ImageWidth") - .HasColumnType("int"); - - b.Property("Instances") - .HasColumnType("int"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("SoftDeleted") - .HasColumnType("datetimeoffset"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ToTable((string)null); - - b.ToView("vw_DuplicateDetails", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.Event", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EventOccurredAt") - .HasColumnType("datetimeoffset"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("Handle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("UpdatedBy") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Width") - .HasColumnType("int"); - - b.ComplexProperty>("Type", "AStar.Dev.Infrastructure.FilesDb.Models.Event.Type#EventType", b1 => - { - b1.IsRequired(); - - b1.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EventName"); - - b1.Property("Value") - .HasColumnType("int") - .HasColumnName("EventType"); - }); - - b.HasKey("Id"); - - b.ToTable("Event", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Celebrity") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.ToTable("FileClassification", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.Property("Id") - .HasColumnType("int"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ComplexProperty>("DeletionStatus", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DeletionStatus#DeletionStatus", b1 => - { - b1.IsRequired(); - - b1.Property("HardDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("HardDeletePending"); - - b1.Property("SoftDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeletePending"); - - b1.Property("SoftDeleted") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeleted"); - }); - - b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => - { - b1.IsRequired(); - - b1.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b1.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - }); - - b.HasKey("Id"); - - b.HasIndex("FileHandle"); - - b.HasIndex("FileName"); - - b.HasIndex("FileSize"); - - b.ToTable("FileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FileClassificationId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.HasIndex("FileClassificationId"); - - b.ToTable("FileNamePart", "files"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileDetailsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileDetailsId"); - - b.HasIndex("FileDetailsId"); - - b.ToTable("FileClassificationFileDetail", "files"); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileNamePartsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileNamePartsId"); - - b.HasIndex("FileNamePartsId"); - - b.ToTable("FileClassificationFileNamePart", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationId"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", null) - .WithMany() - .HasForeignKey("FileDetailsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", null) - .WithMany() - .HasForeignKey("FileNamePartsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.cs deleted file mode 100644 index 01badff..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725184934_RecreateAgain.cs +++ /dev/null @@ -1,218 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations; - -/// -public partial class RecreateAgain : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - _ = migrationBuilder.EnsureSchema( - name: "files"); - - _ = migrationBuilder.CreateTable( - name: "Event", - schema: "files", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - EventOccurredAt = table.Column(type: "datetimeoffset", nullable: false), - FileName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - DirectoryName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Handle = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Width = table.Column(type: "int", nullable: true), - Height = table.Column(type: "int", nullable: true), - FileSize = table.Column(type: "bigint", nullable: false), - FileCreated = table.Column(type: "datetimeoffset", nullable: false), - FileLastModified = table.Column(type: "datetimeoffset", nullable: false), - UpdatedBy = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), - EventName = table.Column(type: "nvarchar(max)", nullable: false), - EventType = table.Column(type: "int", nullable: false) - }, - constraints: table => _ = table.PrimaryKey("PK_Event", x => x.Id)); - - _ = migrationBuilder.CreateTable( - name: "FileClassification", - schema: "files", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Name = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), - Celebrity = table.Column(type: "bit", nullable: false) - }, - constraints: table => _ = table.PrimaryKey("PK_FileClassification", x => x.Id)); - - _ = migrationBuilder.CreateTable( - name: "FileDetail", - schema: "files", - columns: table => new - { - Id = table.Column(type: "int", nullable: false), - FileName = table.Column(type: "nvarchar(256)", nullable: false), - FileSize = table.Column(type: "bigint", nullable: false), - IsImage = table.Column(type: "bit", nullable: false), - FileHandle = table.Column(type: "nvarchar(256)", nullable: false), - FileCreated = table.Column(type: "datetimeoffset", nullable: false), - FileLastModified = table.Column(type: "datetimeoffset", nullable: false), - FileLastViewed = table.Column(type: "datetimeoffset", nullable: true), - MoveRequired = table.Column(type: "bit", nullable: false), - HardDeletePending = table.Column(type: "datetimeoffset", nullable: true), - SoftDeletePending = table.Column(type: "datetimeoffset", nullable: true), - SoftDeleted = table.Column(type: "datetimeoffset", nullable: true), - ImageHeight = table.Column(type: "int", nullable: true), - ImageWidth = table.Column(type: "int", nullable: true), - UpdatedBy = table.Column(type: "nvarchar(max)", nullable: false), - UpdatedOn = table.Column(type: "datetimeoffset", nullable: false) - }, - constraints: table => _ = table.PrimaryKey("PK_FileDetail", x => x.Id)); - - _ = migrationBuilder.CreateTable( - name: "FileNamePart", - schema: "files", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Text = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false), - FileClassificationId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - _ = table.PrimaryKey("PK_FileNamePart", x => x.Id); - - _ = table.ForeignKey( - name: "FK_FileNamePart_FileClassification_FileClassificationId", - column: x => x.FileClassificationId, - principalSchema: "files", - principalTable: "FileClassification", - principalColumn: "Id"); - }); - - _ = migrationBuilder.CreateTable( - name: "FileClassificationFileDetail", - schema: "files", - columns: table => new - { - FileClassificationsId = table.Column(type: "int", nullable: false), - FileDetailsId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - _ = table.PrimaryKey("PK_FileClassificationFileDetail", x => new { x.FileClassificationsId, x.FileDetailsId }); - - _ = table.ForeignKey( - name: "FK_FileClassificationFileDetail_FileClassification_FileClassificationsId", - column: x => x.FileClassificationsId, - principalSchema: "files", - principalTable: "FileClassification", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - _ = table.ForeignKey( - name: "FK_FileClassificationFileDetail_FileDetail_FileDetailsId", - column: x => x.FileDetailsId, - principalSchema: "files", - principalTable: "FileDetail", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - _ = migrationBuilder.CreateTable( - name: "FileClassificationFileNamePart", - schema: "files", - columns: table => new - { - FileClassificationsId = table.Column(type: "int", nullable: false), - FileNamePartsId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - _ = table.PrimaryKey("PK_FileClassificationFileNamePart", x => new { x.FileClassificationsId, x.FileNamePartsId }); - - _ = table.ForeignKey( - name: "FK_FileClassificationFileNamePart_FileClassification_FileClassificationsId", - column: x => x.FileClassificationsId, - principalSchema: "files", - principalTable: "FileClassification", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - _ = table.ForeignKey( - name: "FK_FileClassificationFileNamePart_FileNamePart_FileNamePartsId", - column: x => x.FileNamePartsId, - principalSchema: "files", - principalTable: "FileNamePart", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileClassificationFileDetail_FileDetailsId", - schema: "files", - table: "FileClassificationFileDetail", - column: "FileDetailsId"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileClassificationFileNamePart_FileNamePartsId", - schema: "files", - table: "FileClassificationFileNamePart", - column: "FileNamePartsId"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileDetail_FileHandle", - schema: "files", - table: "FileDetail", - column: "FileHandle"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileDetail_FileName", - schema: "files", - table: "FileDetail", - column: "FileName"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileDetail_FileSize", - schema: "files", - table: "FileDetail", - column: "FileSize"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileNamePart_FileClassificationId", - schema: "files", - table: "FileNamePart", - column: "FileClassificationId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - _ = migrationBuilder.DropTable( - name: "Event", - schema: "files"); - - _ = migrationBuilder.DropTable( - name: "FileClassificationFileDetail", - schema: "files"); - - _ = migrationBuilder.DropTable( - name: "FileClassificationFileNamePart", - schema: "files"); - - _ = migrationBuilder.DropTable( - name: "FileDetail", - schema: "files"); - - _ = migrationBuilder.DropTable( - name: "FileNamePart", - schema: "files"); - - _ = migrationBuilder.DropTable( - name: "FileClassification", - schema: "files"); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.Designer.cs deleted file mode 100644 index 25147bd..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.Designer.cs +++ /dev/null @@ -1,351 +0,0 @@ -// - -using System.Collections.Generic; -using AStar.Dev.Infrastructure.FilesDb.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations -{ - [DbContext(typeof(FilesContext))] - [Migration("20250725190252_RecreateAgain2")] - partial class RecreateAgain2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("files") - .UseCollation("SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("ProductVersion", "9.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.DuplicateDetail", b => - { - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileHandle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("HardDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("ImageHeight") - .HasColumnType("int"); - - b.Property("ImageWidth") - .HasColumnType("int"); - - b.Property("Instances") - .HasColumnType("int"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("SoftDeleted") - .HasColumnType("datetimeoffset"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ToTable((string)null); - - b.ToView("vw_DuplicateDetails", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.Event", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EventOccurredAt") - .HasColumnType("datetimeoffset"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("Handle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("UpdatedBy") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Width") - .HasColumnType("int"); - - b.ComplexProperty>("Type", "AStar.Dev.Infrastructure.FilesDb.Models.Event.Type#EventType", b1 => - { - b1.IsRequired(); - - b1.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EventName"); - - b1.Property("Value") - .HasColumnType("int") - .HasColumnName("EventType"); - }); - - b.HasKey("Id"); - - b.ToTable("Event", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Celebrity") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.ToTable("FileClassification", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.Property("Id") - .HasColumnType("int"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ComplexProperty>("DeletionStatus", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DeletionStatus#DeletionStatus", b1 => - { - b1.IsRequired(); - - b1.Property("HardDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("HardDeletePending"); - - b1.Property("SoftDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeletePending"); - - b1.Property("SoftDeleted") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeleted"); - }); - - b.ComplexProperty>("DirectoryName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DirectoryName#DirectoryName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("DirectoryName"); - }); - - b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => - { - b1.IsRequired(); - - b1.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b1.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - }); - - b.HasKey("Id"); - - b.HasIndex("FileHandle"); - - b.HasIndex("FileName"); - - b.HasIndex("FileSize"); - - b.ToTable("FileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FileClassificationId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.HasIndex("FileClassificationId"); - - b.ToTable("FileNamePart", "files"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileDetailsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileDetailsId"); - - b.HasIndex("FileDetailsId"); - - b.ToTable("FileClassificationFileDetail", "files"); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileNamePartsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileNamePartsId"); - - b.HasIndex("FileNamePartsId"); - - b.ToTable("FileClassificationFileNamePart", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationId"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", null) - .WithMany() - .HasForeignKey("FileDetailsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", null) - .WithMany() - .HasForeignKey("FileNamePartsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.cs deleted file mode 100644 index 821b1f2..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250725190252_RecreateAgain2.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations; - -/// -public partial class RecreateAgain2 : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - => migrationBuilder.AddColumn( - name: "DirectoryName", - schema: "files", - table: "FileDetail", - type: "nvarchar(256)", - nullable: false, - defaultValue: ""); - - /// - protected override void Down(MigrationBuilder migrationBuilder) - => migrationBuilder.DropColumn( - name: "DirectoryName", - schema: "files", - table: "FileDetail"); -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.Designer.cs deleted file mode 100644 index a83c27b..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.Designer.cs +++ /dev/null @@ -1,353 +0,0 @@ -// - -using System.Collections.Generic; -using AStar.Dev.Infrastructure.FilesDb.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations -{ - [DbContext(typeof(FilesContext))] - [Migration("20250729201535_UpdateFileNameConfiguration")] - partial class UpdateFileNameConfiguration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("files") - .UseCollation("SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("ProductVersion", "9.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.DuplicateDetail", b => - { - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileHandle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("HardDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("ImageHeight") - .HasColumnType("int"); - - b.Property("ImageWidth") - .HasColumnType("int"); - - b.Property("Instances") - .HasColumnType("int"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("SoftDeleted") - .HasColumnType("datetimeoffset"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ToTable((string)null); - - b.ToView("vw_DuplicateDetails", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.Event", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EventOccurredAt") - .HasColumnType("datetimeoffset"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("Handle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("UpdatedBy") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Width") - .HasColumnType("int"); - - b.ComplexProperty>("Type", "AStar.Dev.Infrastructure.FilesDb.Models.Event.Type#EventType", b1 => - { - b1.IsRequired(); - - b1.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EventName"); - - b1.Property("Value") - .HasColumnType("int") - .HasColumnName("EventType"); - }); - - b.HasKey("Id"); - - b.ToTable("Event", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Celebrity") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.ToTable("FileClassification", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.Property("Id") - .HasColumnType("int"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ComplexProperty>("DeletionStatus", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DeletionStatus#DeletionStatus", b1 => - { - b1.IsRequired(); - - b1.Property("HardDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("HardDeletePending"); - - b1.Property("SoftDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeletePending"); - - b1.Property("SoftDeleted") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeleted"); - }); - - b.ComplexProperty>("DirectoryName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DirectoryName#DirectoryName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("DirectoryName"); - }); - - b.ComplexProperty>("FileName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.FileName#FileName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("FileName"); - }); - - b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => - { - b1.IsRequired(); - - b1.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b1.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - }); - - b.HasKey("Id"); - - b.HasIndex("FileHandle"); - - b.HasIndex("FileSize"); - - b.ToTable("FileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FileClassificationId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.HasIndex("FileClassificationId"); - - b.ToTable("FileNamePart", "files"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileDetailsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileDetailsId"); - - b.HasIndex("FileDetailsId"); - - b.ToTable("FileClassificationFileDetail", "files"); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileNamePartsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileNamePartsId"); - - b.HasIndex("FileNamePartsId"); - - b.ToTable("FileClassificationFileNamePart", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationId"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", null) - .WithMany() - .HasForeignKey("FileDetailsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", null) - .WithMany() - .HasForeignKey("FileNamePartsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.cs deleted file mode 100644 index 96028ca..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729201535_UpdateFileNameConfiguration.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations; - -/// -public partial class UpdateFileNameConfiguration : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - => migrationBuilder.DropIndex( - name: "IX_FileDetail_FileName", - schema: "files", - table: "FileDetail"); - - /// - protected override void Down(MigrationBuilder migrationBuilder) - => migrationBuilder.CreateIndex( - name: "IX_FileDetail_FileName", - schema: "files", - table: "FileDetail", - column: "FileName"); -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.Designer.cs deleted file mode 100644 index 1f1b5f3..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.Designer.cs +++ /dev/null @@ -1,353 +0,0 @@ -// - -using System.Collections.Generic; -using AStar.Dev.Infrastructure.FilesDb.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations -{ - [DbContext(typeof(FilesContext))] - [Migration("20250729202510_AddFileDetailIndexes")] - partial class AddFileDetailIndexes - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("files") - .UseCollation("SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("ProductVersion", "9.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.DuplicateDetail", b => - { - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileHandle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("HardDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("ImageHeight") - .HasColumnType("int"); - - b.Property("ImageWidth") - .HasColumnType("int"); - - b.Property("Instances") - .HasColumnType("int"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("SoftDeleted") - .HasColumnType("datetimeoffset"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ToTable((string)null); - - b.ToView("vw_DuplicateDetails", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.Event", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EventOccurredAt") - .HasColumnType("datetimeoffset"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("Handle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("UpdatedBy") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Width") - .HasColumnType("int"); - - b.ComplexProperty>("Type", "AStar.Dev.Infrastructure.FilesDb.Models.Event.Type#EventType", b1 => - { - b1.IsRequired(); - - b1.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EventName"); - - b1.Property("Value") - .HasColumnType("int") - .HasColumnName("EventType"); - }); - - b.HasKey("Id"); - - b.ToTable("Event", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Celebrity") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.ToTable("FileClassification", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.Property("Id") - .HasColumnType("int"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ComplexProperty>("DeletionStatus", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DeletionStatus#DeletionStatus", b1 => - { - b1.IsRequired(); - - b1.Property("HardDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("HardDeletePending"); - - b1.Property("SoftDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeletePending"); - - b1.Property("SoftDeleted") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeleted"); - }); - - b.ComplexProperty>("DirectoryName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DirectoryName#DirectoryName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("DirectoryName"); - }); - - b.ComplexProperty>("FileName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.FileName#FileName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("FileName"); - }); - - b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => - { - b1.IsRequired(); - - b1.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b1.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - }); - - b.HasKey("Id"); - - b.HasIndex("FileHandle"); - - b.HasIndex("FileSize"); - - b.ToTable("FileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FileClassificationId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.HasIndex("FileClassificationId"); - - b.ToTable("FileNamePart", "files"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileDetailsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileDetailsId"); - - b.HasIndex("FileDetailsId"); - - b.ToTable("FileClassificationFileDetail", "files"); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileNamePartsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileNamePartsId"); - - b.HasIndex("FileNamePartsId"); - - b.ToTable("FileClassificationFileNamePart", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationId"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", null) - .WithMany() - .HasForeignKey("FileDetailsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", null) - .WithMany() - .HasForeignKey("FileNamePartsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.cs deleted file mode 100644 index 3990a25..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250729202510_AddFileDetailIndexes.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations; - -/// -public partial class AddFileDetailIndexes : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - // NAR - the code changes did not produce a dB change - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - // NAR - the code changes did not produce a dB change - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.Designer.cs deleted file mode 100644 index 72fb318..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.Designer.cs +++ /dev/null @@ -1,359 +0,0 @@ -// - -using System.Collections.Generic; -using AStar.Dev.Infrastructure.FilesDb.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations -{ - [DbContext(typeof(FilesContext))] - [Migration("20250808163238_AddDuplicateImagesIndex")] - partial class AddDuplicateImagesIndex - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("files") - .UseCollation("SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("ProductVersion", "9.0.7") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.DuplicateDetail", b => - { - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileHandle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("HardDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("ImageHeight") - .HasColumnType("int"); - - b.Property("ImageWidth") - .HasColumnType("int"); - - b.Property("Instances") - .HasColumnType("int"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("datetimeoffset"); - - b.Property("SoftDeleted") - .HasColumnType("datetimeoffset"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ToTable((string)null); - - b.ToView("vw_DuplicateDetails", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.Event", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EventOccurredAt") - .HasColumnType("datetimeoffset"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("Handle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("UpdatedBy") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Width") - .HasColumnType("int"); - - b.ComplexProperty>("Type", "AStar.Dev.Infrastructure.FilesDb.Models.Event.Type#EventType", b1 => - { - b1.IsRequired(); - - b1.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EventName"); - - b1.Property("Value") - .HasColumnType("int") - .HasColumnName("EventType"); - }); - - b.HasKey("Id"); - - b.ToTable("Event", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Celebrity") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.ToTable("FileClassification", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.Property("Id") - .HasColumnType("int"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastViewed") - .HasColumnType("datetimeoffset"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetimeoffset"); - - b.ComplexProperty>("DeletionStatus", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DeletionStatus#DeletionStatus", b1 => - { - b1.IsRequired(); - - b1.Property("HardDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("HardDeletePending"); - - b1.Property("SoftDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeletePending"); - - b1.Property("SoftDeleted") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeleted"); - }); - - b.ComplexProperty>("DirectoryName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DirectoryName#DirectoryName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("DirectoryName"); - }); - - b.ComplexProperty>("FileName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.FileName#FileName", b1 => - { - b1.IsRequired(); - - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("FileName"); - }); - - b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => - { - b1.IsRequired(); - - b1.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b1.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - }); - - b.HasKey("Id"); - - b.HasIndex("FileHandle") - .IsUnique(); - - b.HasIndex("FileSize"); - - b.HasIndex("IsImage", "FileSize") - .HasDatabaseName("IX_FileDetail_DuplicateImages"); - - b.ToTable("FileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FileClassificationId") - .HasColumnType("int"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.HasKey("Id"); - - b.HasIndex("FileClassificationId"); - - b.ToTable("FileNamePart", "files"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileDetailsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileDetailsId"); - - b.HasIndex("FileDetailsId"); - - b.ToTable("FileClassificationFileDetail", "files"); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileNamePartsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileNamePartsId"); - - b.HasIndex("FileNamePartsId"); - - b.ToTable("FileClassificationFileNamePart", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationId"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", null) - .WithMany() - .HasForeignKey("FileDetailsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("FileClassificationFileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", null) - .WithMany() - .HasForeignKey("FileNamePartsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.cs deleted file mode 100644 index c3d91b0..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250808163238_AddDuplicateImagesIndex.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations; - -/// -public partial class AddDuplicateImagesIndex : Migration -{ - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - _ = migrationBuilder.DropIndex( - name: "IX_FileDetail_FileHandle", - schema: "files", - table: "FileDetail"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileDetail_DuplicateImages", - schema: "files", - table: "FileDetail", - columns: ["IsImage", "FileSize"]); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileDetail_FileHandle", - schema: "files", - table: "FileDetail", - column: "FileHandle", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - _ = migrationBuilder.DropIndex( - name: "IX_FileDetail_DuplicateImages", - schema: "files", - table: "FileDetail"); - - _ = migrationBuilder.DropIndex( - name: "IX_FileDetail_FileHandle", - schema: "files", - table: "FileDetail"); - - _ = migrationBuilder.CreateIndex( - name: "IX_FileDetail_FileHandle", - schema: "files", - table: "FileDetail", - column: "FileHandle"); - } -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.Designer.cs deleted file mode 100644 index d1c9536..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.Designer.cs +++ /dev/null @@ -1,430 +0,0 @@ -// -using System; -using System.Collections.Generic; -using AStar.Dev.Infrastructure.FilesDb.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations -{ - [DbContext(typeof(FilesContext))] - [Migration("20250919204057_InitialCreation")] - partial class InitialCreation - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("files") - .UseCollation("SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("ProductVersion", "9.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.DuplicatesDetails", b => - { - b.Property("DetailsLastUpdated") - .HasColumnType("datetime2"); - - b.Property("DirectoryName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FileAccessDetailId") - .HasColumnType("int"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FileName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("HardDeletePending") - .HasColumnType("bit"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("Id") - .HasColumnType("int"); - - b.Property("Instances") - .HasColumnType("int"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.Property("LastViewed") - .HasColumnType("datetime2"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("bit"); - - b.Property("SoftDeleted") - .HasColumnType("bit"); - - b.Property("Width") - .HasColumnType("int"); - - b.ToTable((string)null); - - b.ToView("vw_DuplicatesDetails", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.Event", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DirectoryName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EventOccurredAt") - .HasColumnType("datetimeoffset"); - - b.Property("FileCreated") - .HasColumnType("datetimeoffset"); - - b.Property("FileLastModified") - .HasColumnType("datetimeoffset"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("Handle") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Height") - .HasColumnType("int"); - - b.Property("UpdatedBy") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("Width") - .HasColumnType("int"); - - b.ComplexProperty>("Type", "AStar.Dev.Infrastructure.FilesDb.Models.Event.Type#EventType", b1 => - { - b1.IsRequired(); - - b1.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EventName"); - - b1.Property("Value") - .HasColumnType("int") - .HasColumnName("EventType"); - }); - - b.HasKey("Id"); - - b.ToTable("Event", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileAccessDetail", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DetailsLastUpdated") - .HasColumnType("datetime2"); - - b.Property("HardDeletePending") - .HasColumnType("bit"); - - b.Property("HardDeleted") - .HasColumnType("bit"); - - b.Property("LastViewed") - .HasColumnType("datetime2"); - - b.Property("MoveRequired") - .HasColumnType("bit"); - - b.Property("SoftDeletePending") - .HasColumnType("bit"); - - b.Property("SoftDeleted") - .HasColumnType("bit"); - - b.HasKey("Id"); - - b.ToTable("FileAccessDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Celebrity") - .HasColumnType("bit"); - - b.Property("IncludeInSearch") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("FileClassification", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.Property("Id") - .HasColumnType("int"); - - b.Property("FileAccessDetailId") - .HasColumnType("int"); - - b.Property("FileHandle") - .IsRequired() - .HasColumnType("nvarchar(256)"); - - b.Property("FileSize") - .HasColumnType("bigint"); - - b.Property("IsImage") - .HasColumnType("bit"); - - b.ComplexProperty>("DeletionStatus", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DeletionStatus#DeletionStatus", b1 => - { - b1.IsRequired(); - - b1.Property("HardDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("HardDeletePending"); - - b1.Property("SoftDeletePending") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeletePending"); - - b1.Property("SoftDeleted") - .HasColumnType("datetimeoffset") - .HasColumnName("SoftDeleted"); - }); - - b.ComplexProperty>("DirectoryName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.DirectoryName#DirectoryName", b1 => - { - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("DirectoryName"); - }); - - b.ComplexProperty>("FileName", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.FileName#FileName", b1 => - { - b1.IsRequired(); - - b1.Property("Value") - .IsRequired() - .HasColumnType("nvarchar(256)") - .HasColumnName("FileName"); - }); - - b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => - { - b1.IsRequired(); - - b1.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b1.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - }); - - b.HasKey("Id"); - - b.HasIndex("FileAccessDetailId"); - - b.HasIndex("FileHandle") - .IsUnique(); - - b.HasIndex("FileSize"); - - b.HasIndex("IsImage", "FileSize") - .HasDatabaseName("IX_FileDetail_DuplicateImages"); - - b.ToTable("FileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FileClassificationId") - .HasColumnType("int"); - - b.Property("IncludeInSearch") - .HasColumnType("bit"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("UpdatedBy") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedOn") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("FileClassificationId"); - - b.ToTable("FileNamePart", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.ModelToIgnore", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Value") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.ToTable("ModelToIgnore", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.TagToIgnore", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("IgnoreImage") - .HasColumnType("bit"); - - b.Property("Value") - .IsRequired() - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.HasKey("Id"); - - b.ToTable("TagToIgnore", "files"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.Property("FileClassificationsId") - .HasColumnType("int"); - - b.Property("FileDetailsId") - .HasColumnType("int"); - - b.HasKey("FileClassificationsId", "FileDetailsId"); - - b.HasIndex("FileDetailsId"); - - b.ToTable("FileClassificationFileDetail", "files"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileAccessDetail", "FileAccessDetail") - .WithMany() - .HasForeignKey("FileAccessDetailId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("FileAccessDetail"); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany("FileNameParts") - .HasForeignKey("FileClassificationId"); - }); - - modelBuilder.Entity("FileClassificationFileDetail", b => - { - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", null) - .WithMany() - .HasForeignKey("FileClassificationsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.FileDetail", null) - .WithMany() - .HasForeignKey("FileDetailsId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileClassification", b => - { - b.Navigation("FileNameParts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.cs deleted file mode 100644 index 9082001..0000000 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.cs +++ /dev/null @@ -1,244 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AStar.Dev.Infrastructure.FilesDb.Migrations; - -/// -public partial class RestructureDeletionAndImageDetails : Migration -{ -#pragma warning disable IDE0058 // Unnecessary assignment of a value - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "HardDeletePending", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "ImageHeight", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "ImageWidth", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "SoftDeletePending", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "SoftDeleted", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "HardDeletePending", - schema: "files", - table: "FileAccessDetail"); - - migrationBuilder.DropColumn( - name: "HardDeleted", - schema: "files", - table: "FileAccessDetail"); - - migrationBuilder.DropColumn( - name: "SoftDeletePending", - schema: "files", - table: "FileAccessDetail"); - - migrationBuilder.DropColumn( - name: "SoftDeleted", - schema: "files", - table: "FileAccessDetail"); - - migrationBuilder.AddColumn( - name: "DeletionStatusId", - schema: "files", - table: "FileDetail", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "ImageDetailId", - schema: "files", - table: "FileDetail", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateTable( - name: "DeletionStatus", - schema: "files", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - SoftDeleted = table.Column(type: "datetimeoffset", nullable: true), - SoftDeletePending = table.Column(type: "datetimeoffset", nullable: true), - HardDeletePending = table.Column(type: "datetimeoffset", nullable: true) - }, - constraints: table => table.PrimaryKey("PK_DeletionStatus", x => x.Id)); - - migrationBuilder.CreateTable( - name: "ImageDetail", - schema: "files", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ImageWidth = table.Column(type: "int", nullable: true), - ImageHeight = table.Column(type: "int", nullable: true) - }, - constraints: table => table.PrimaryKey("PK_ImageDetail", x => x.Id)); - - migrationBuilder.CreateIndex( - name: "IX_FileDetail_DeletionStatusId", - schema: "files", - table: "FileDetail", - column: "DeletionStatusId"); - - migrationBuilder.CreateIndex( - name: "IX_FileDetail_ImageDetailId", - schema: "files", - table: "FileDetail", - column: "ImageDetailId"); - - migrationBuilder.AddForeignKey( - name: "FK_FileDetail_DeletionStatus_DeletionStatusId", - schema: "files", - table: "FileDetail", - column: "DeletionStatusId", - principalSchema: "files", - principalTable: "DeletionStatus", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_FileDetail_ImageDetail_ImageDetailId", - schema: "files", - table: "FileDetail", - column: "ImageDetailId", - principalSchema: "files", - principalTable: "ImageDetail", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_FileDetail_DeletionStatus_DeletionStatusId", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropForeignKey( - name: "FK_FileDetail_ImageDetail_ImageDetailId", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropTable( - name: "DeletionStatus", - schema: "files"); - - migrationBuilder.DropTable( - name: "ImageDetail", - schema: "files"); - - migrationBuilder.DropIndex( - name: "IX_FileDetail_DeletionStatusId", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropIndex( - name: "IX_FileDetail_ImageDetailId", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "DeletionStatusId", - schema: "files", - table: "FileDetail"); - - migrationBuilder.DropColumn( - name: "ImageDetailId", - schema: "files", - table: "FileDetail"); - - migrationBuilder.AddColumn( - name: "HardDeletePending", - schema: "files", - table: "FileDetail", - type: "datetimeoffset", - nullable: true); - - migrationBuilder.AddColumn( - name: "ImageHeight", - schema: "files", - table: "FileDetail", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "ImageWidth", - schema: "files", - table: "FileDetail", - type: "int", - nullable: true); - - migrationBuilder.AddColumn( - name: "SoftDeletePending", - schema: "files", - table: "FileDetail", - type: "datetimeoffset", - nullable: true); - - migrationBuilder.AddColumn( - name: "SoftDeleted", - schema: "files", - table: "FileDetail", - type: "datetimeoffset", - nullable: true); - - migrationBuilder.AddColumn( - name: "HardDeletePending", - schema: "files", - table: "FileAccessDetail", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "HardDeleted", - schema: "files", - table: "FileAccessDetail", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "SoftDeletePending", - schema: "files", - table: "FileAccessDetail", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "SoftDeleted", - schema: "files", - table: "FileAccessDetail", - type: "bit", - nullable: false, - defaultValue: false); - } - -#pragma warning restore IDE0058 // Unnecessary assignment of a value -} \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.Designer.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250922202225_RecreateDatabase.Designer.cs similarity index 90% rename from src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.Designer.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250922202225_RecreateDatabase.Designer.cs index 5774364..161f7e4 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919211728_RestructureDeletionAndImageDetails.Designer.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250922202225_RecreateDatabase.Designer.cs @@ -13,8 +13,8 @@ namespace AStar.Dev.Infrastructure.FilesDb.Migrations { [DbContext(typeof(FilesContext))] - [Migration("20250919211728_RestructureDeletionAndImageDetails")] - partial class RestructureDeletionAndImageDetails + [Migration("20250922202225_RecreateDatabase")] + partial class RecreateDatabase { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -221,8 +221,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("UpdatedOn") - .HasColumnType("datetime2"); + b.Property("UpdatedOn") + .HasColumnType("datetimeoffset"); b.HasKey("Id"); @@ -237,6 +237,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("int"); + b.Property("CreatedDate") + .HasColumnType("datetimeoffset"); + b.Property("DeletionStatusId") .HasColumnType("int"); @@ -250,9 +253,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("FileSize") .HasColumnType("bigint"); - b.Property("ImageDetailId") - .HasColumnType("int"); - b.Property("IsImage") .HasColumnType("bit"); @@ -274,6 +274,19 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnName("FileName"); }); + b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => + { + b1.IsRequired(); + + b1.Property("Height") + .HasColumnType("int") + .HasColumnName("ImageHeight"); + + b1.Property("Width") + .HasColumnType("int") + .HasColumnName("ImageWidth"); + }); + b.HasKey("Id"); b.HasIndex("DeletionStatusId"); @@ -285,8 +298,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("FileSize"); - b.HasIndex("ImageDetailId"); - b.HasIndex("IsImage", "FileSize") .HasDatabaseName("IX_FileDetail_DuplicateImages"); @@ -316,8 +327,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("UpdatedOn") - .HasColumnType("datetime2"); + b.Property("UpdatedOn") + .HasColumnType("datetimeoffset"); b.HasKey("Id"); @@ -326,27 +337,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("FileNamePart", "files"); }); - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.ImageDetail", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - - b.HasKey("Id"); - - b.ToTable("ImageDetail", "files"); - }); - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.ModelToIgnore", b => { b.Property("Id") @@ -415,17 +405,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.ImageDetail", "ImageDetail") - .WithMany() - .HasForeignKey("ImageDetailId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - b.Navigation("DeletionStatus"); b.Navigation("FileAccessDetail"); - - b.Navigation("ImageDetail"); }); modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250922202225_RecreateDatabase.cs similarity index 79% rename from src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.cs rename to src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250922202225_RecreateDatabase.cs index d7ffe29..a7fe097 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250919204057_InitialCreation.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/20250922202225_RecreateDatabase.cs @@ -1,13 +1,15 @@ using System; +using System.Diagnostics.CodeAnalysis; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace AStar.Dev.Infrastructure.FilesDb.Migrations; -#pragma warning disable IDE0058 // Unnecessary assignment of a value /// -public partial class InitialCreation : Migration +[SuppressMessage("Style", "IDE0058:Expression value is never used")] +[SuppressMessage("Style", "IDE0053:Use expression body for lambda expression")] +public partial class RecreateDatabase : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -15,6 +17,22 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.EnsureSchema( name: "files"); + migrationBuilder.CreateTable( + name: "DeletionStatus", + schema: "files", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SoftDeleted = table.Column(type: "datetimeoffset", nullable: true), + SoftDeletePending = table.Column(type: "datetimeoffset", nullable: true), + HardDeletePending = table.Column(type: "datetimeoffset", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DeletionStatus", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Event", schema: "files", @@ -35,7 +53,10 @@ protected override void Up(MigrationBuilder migrationBuilder) EventName = table.Column(type: "nvarchar(max)", nullable: false), EventType = table.Column(type: "int", nullable: false) }, - constraints: table => table.PrimaryKey("PK_Event", x => x.Id)); + constraints: table => + { + table.PrimaryKey("PK_Event", x => x.Id); + }); migrationBuilder.CreateTable( name: "FileAccessDetail", @@ -46,13 +67,12 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("SqlServer:Identity", "1, 1"), DetailsLastUpdated = table.Column(type: "datetime2", nullable: true), LastViewed = table.Column(type: "datetime2", nullable: true), - SoftDeleted = table.Column(type: "bit", nullable: false), - SoftDeletePending = table.Column(type: "bit", nullable: false), - MoveRequired = table.Column(type: "bit", nullable: false), - HardDeletePending = table.Column(type: "bit", nullable: false), - HardDeleted = table.Column(type: "bit", nullable: false) + MoveRequired = table.Column(type: "bit", nullable: false) }, - constraints: table => table.PrimaryKey("PK_FileAccessDetail", x => x.Id)); + constraints: table => + { + table.PrimaryKey("PK_FileAccessDetail", x => x.Id); + }); migrationBuilder.CreateTable( name: "FileClassification", @@ -65,9 +85,12 @@ protected override void Up(MigrationBuilder migrationBuilder) Celebrity = table.Column(type: "bit", nullable: false), IncludeInSearch = table.Column(type: "bit", nullable: false), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: false), - UpdatedOn = table.Column(type: "datetime2", nullable: false) + UpdatedOn = table.Column(type: "datetimeoffset", nullable: false) }, - constraints: table => table.PrimaryKey("PK_FileClassification", x => x.Id)); + constraints: table => + { + table.PrimaryKey("PK_FileClassification", x => x.Id); + }); migrationBuilder.CreateTable( name: "ModelToIgnore", @@ -78,7 +101,10 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("SqlServer:Identity", "1, 1"), Value = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false) }, - constraints: table => table.PrimaryKey("PK_ModelToIgnore", x => x.Id)); + constraints: table => + { + table.PrimaryKey("PK_ModelToIgnore", x => x.Id); + }); migrationBuilder.CreateTable( name: "TagToIgnore", @@ -90,7 +116,10 @@ protected override void Up(MigrationBuilder migrationBuilder) Value = table.Column(type: "nvarchar(300)", maxLength: 300, nullable: false), IgnoreImage = table.Column(type: "bit", nullable: false) }, - constraints: table => table.PrimaryKey("PK_TagToIgnore", x => x.Id)); + constraints: table => + { + table.PrimaryKey("PK_TagToIgnore", x => x.Id); + }); migrationBuilder.CreateTable( name: "FileDetail", @@ -100,11 +129,10 @@ protected override void Up(MigrationBuilder migrationBuilder) Id = table.Column(type: "int", nullable: false), FileAccessDetailId = table.Column(type: "int", nullable: false), FileSize = table.Column(type: "bigint", nullable: false), + CreatedDate = table.Column(type: "datetimeoffset", nullable: false), IsImage = table.Column(type: "bit", nullable: false), FileHandle = table.Column(type: "nvarchar(256)", nullable: false), - HardDeletePending = table.Column(type: "datetimeoffset", nullable: true), - SoftDeletePending = table.Column(type: "datetimeoffset", nullable: true), - SoftDeleted = table.Column(type: "datetimeoffset", nullable: true), + DeletionStatusId = table.Column(type: "int", nullable: false), DirectoryName = table.Column(type: "nvarchar(256)", nullable: false), FileName = table.Column(type: "nvarchar(256)", nullable: false), ImageHeight = table.Column(type: "int", nullable: true), @@ -113,6 +141,13 @@ protected override void Up(MigrationBuilder migrationBuilder) constraints: table => { table.PrimaryKey("PK_FileDetail", x => x.Id); + table.ForeignKey( + name: "FK_FileDetail_DeletionStatus_DeletionStatusId", + column: x => x.DeletionStatusId, + principalSchema: "files", + principalTable: "DeletionStatus", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_FileDetail_FileAccessDetail_FileAccessDetailId", column: x => x.FileAccessDetailId, @@ -133,7 +168,7 @@ protected override void Up(MigrationBuilder migrationBuilder) IncludeInSearch = table.Column(type: "bit", nullable: false), FileClassificationId = table.Column(type: "int", nullable: true), UpdatedBy = table.Column(type: "nvarchar(max)", nullable: false), - UpdatedOn = table.Column(type: "datetime2", nullable: false) + UpdatedOn = table.Column(type: "datetimeoffset", nullable: false) }, constraints: table => { @@ -186,11 +221,21 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "FileClassificationFileDetail", column: "FileDetailsId"); + migrationBuilder.CreateIndex( + name: "IX_FileDetail_DeletionStatusId", + schema: "files", + table: "FileDetail", + column: "DeletionStatusId"); + +#pragma warning disable IDE0058 migrationBuilder.CreateIndex( name: "IX_FileDetail_DuplicateImages", schema: "files", table: "FileDetail", - columns: ["IsImage", "FileSize"]); +#pragma warning disable CA1861 + columns: new[] { "IsImage", "FileSize" }); +#pragma warning restore CA1861 +#pragma warning restore IDE0058 migrationBuilder.CreateIndex( name: "IX_FileDetail_FileAccessDetailId", @@ -249,10 +294,12 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "FileClassification", schema: "files"); + migrationBuilder.DropTable( + name: "DeletionStatus", + schema: "files"); + migrationBuilder.DropTable( name: "FileAccessDetail", schema: "files"); } - -#pragma warning restore IDE0058 // Unnecessary assignment of a value } \ No newline at end of file diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/FilesContextModelSnapshot.cs b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/FilesContextModelSnapshot.cs index d12b0e1..252cad0 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Migrations/FilesContextModelSnapshot.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Migrations/FilesContextModelSnapshot.cs @@ -218,8 +218,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("UpdatedOn") - .HasColumnType("datetime2"); + b.Property("UpdatedOn") + .HasColumnType("datetimeoffset"); b.HasKey("Id"); @@ -234,6 +234,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("int"); + b.Property("CreatedDate") + .HasColumnType("datetimeoffset"); + b.Property("DeletionStatusId") .HasColumnType("int"); @@ -247,9 +250,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("FileSize") .HasColumnType("bigint"); - b.Property("ImageDetailId") - .HasColumnType("int"); - b.Property("IsImage") .HasColumnType("bit"); @@ -271,6 +271,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnName("FileName"); }); + b.ComplexProperty>("ImageDetail", "AStar.Dev.Infrastructure.FilesDb.Models.FileDetail.ImageDetail#ImageDetail", b1 => + { + b1.IsRequired(); + + b1.Property("Height") + .HasColumnType("int") + .HasColumnName("ImageHeight"); + + b1.Property("Width") + .HasColumnType("int") + .HasColumnName("ImageWidth"); + }); + b.HasKey("Id"); b.HasIndex("DeletionStatusId"); @@ -282,8 +295,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("FileSize"); - b.HasIndex("ImageDetailId"); - b.HasIndex("IsImage", "FileSize") .HasDatabaseName("IX_FileDetail_DuplicateImages"); @@ -313,8 +324,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("UpdatedOn") - .HasColumnType("datetime2"); + b.Property("UpdatedOn") + .HasColumnType("datetimeoffset"); b.HasKey("Id"); @@ -323,27 +334,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("FileNamePart", "files"); }); - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.ImageDetail", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Height") - .HasColumnType("int") - .HasColumnName("ImageHeight"); - - b.Property("Width") - .HasColumnType("int") - .HasColumnName("ImageWidth"); - - b.HasKey("Id"); - - b.ToTable("ImageDetail", "files"); - }); - modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.ModelToIgnore", b => { b.Property("Id") @@ -412,17 +402,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("AStar.Dev.Infrastructure.FilesDb.Models.ImageDetail", "ImageDetail") - .WithMany() - .HasForeignKey("ImageDetailId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - b.Navigation("DeletionStatus"); b.Navigation("FileAccessDetail"); - - b.Navigation("ImageDetail"); }); modelBuilder.Entity("AStar.Dev.Infrastructure.FilesDb.Models.FileNamePart", b => diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Models/FileDetail.cs b/src/AStar.Dev.Infrastructure.FilesDb/Models/FileDetail.cs index 8b98f02..44d6437 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Models/FileDetail.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Models/FileDetail.cs @@ -60,13 +60,18 @@ public FileDetail(IFileInfo fileInfo) /// /// Gets or sets the height of the image. I know, shocking... /// - public ImageDetail ImageDetail { get; set; } = new(); + public ImageDetail ImageDetail { get; set; } = new(null, null); /// /// Gets or sets the file size. I know, shocking... /// public long FileSize { get; set; } + /// + /// Gets or sets the file Creation Date. I know, shocking... + /// + public DateTimeOffset CreatedDate { get; set; } + /// /// Gets or sets whether the file is of a supported image type /// diff --git a/src/AStar.Dev.Infrastructure.FilesDb/Models/ImageDetail.cs b/src/AStar.Dev.Infrastructure.FilesDb/Models/ImageDetail.cs index e5e6b89..091f227 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/Models/ImageDetail.cs +++ b/src/AStar.Dev.Infrastructure.FilesDb/Models/ImageDetail.cs @@ -1,18 +1,8 @@ -namespace AStar.Dev.Infrastructure.FilesDb.Models; +using Microsoft.EntityFrameworkCore; + +namespace AStar.Dev.Infrastructure.FilesDb.Models; /// /// -public sealed class ImageDetail -{ - /// - /// - public int Id { get; set; } - - /// - /// - public int? Width { get; set; } - - /// - /// - public int? Height { get; set; } -} +[Index(nameof(Width), nameof(Height))] +public record ImageDetail(int? Width, int? Height); \ No newline at end of file From d9ee1f2ad9a61ad0d2f50d91d463954f43f4b634 Mon Sep 17 00:00:00 2001 From: Jason Barden Date: Mon, 22 Sep 2025 21:33:26 +0100 Subject: [PATCH 2/2] Update the missed project detail --- .../AStar.Dev.Infrastructure.FilesDb.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj b/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj index 9732a58..5afbe8c 100644 --- a/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj +++ b/src/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj @@ -30,8 +30,8 @@ https://github.com/astar-development/astar-dev-infrastructure-filesdb.git snupkg AStar Dev Infrastructure FilesDb - Rework the File Classifications area and update for AStar Functional Results. - 0.2.0 + Rework the Image Details and Add File Created date. + 0.2.1