diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/DirectoryScanFingerprintEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/DirectoryScanFingerprintEntity.cs
new file mode 100644
index 00000000..8da50a5d
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/DirectoryScanFingerprintEntity.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+
+///
+/// Repository entity for a directory scan fingerprint, holding the last write time of a directory of a media library, used to skip the scanning of directories that have not changed since the last scan.
+///
+[DebuggerDisplay("Id: {Id}; Path: {Path}")]
+public class DirectoryScanFingerprintEntity : IStorageEntity
+{
+ ///
+ /// Gets the Id of the directory scan fingerprint.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets the Id of the media library to which this directory scan fingerprint belongs.
+ ///
+ public required Guid LibraryId { get; init; }
+
+ ///
+ /// Gets the path of the directory to which this directory scan fingerprint belongs.
+ ///
+ public required string Path { get; init; }
+
+ ///
+ /// Gets the last write time of the directory, in UTC, at the moment when the directory was scanned.
+ ///
+ public required DateTime LastWriteTimeUtc { get; init; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs
index 8ccc1472..81810acc 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs
@@ -23,6 +23,11 @@ public class LibraryScanResultEntity : IStorageEntity
///
public required Guid LibraryScanId { get; init; }
+ ///
+ /// Gets the status of the media library scan file.
+ ///
+ public required LibraryScanFileStatus Status { get; init; }
+
///
/// Gets the path of the media library scan file.
///
@@ -39,9 +44,9 @@ public class LibraryScanResultEntity : IStorageEntity
public required long FileSize { get; init; }
///
- /// Gets the modification date of the media library scan file.
+ /// Gets the time and date when the file system file was last modified, stored in ticks.
///
- public required DateTime LastModified { get; init; }
+ public required long Ticks { get; init; }
///
/// Gets the media library scan that this scan result belongs to.
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanSnapshotEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanSnapshotEntity.cs
new file mode 100644
index 00000000..acf4713d
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanSnapshotEntity.cs
@@ -0,0 +1,69 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+
+///
+/// Repository entity for a media library item, representing the current state of a previously scanned media item, as a snapshot.
+///
+[DebuggerDisplay("Id: {Id}; Path: {Path}")]
+public class LibraryScanSnapshotEntity : IStorageEntity, IAuditableEntity
+{
+ ///
+ /// Gets the Id of the media library scan snapshot item.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets the Id of the media library to which this media library scan snapshot item belongs.
+ ///
+ public required Guid LibraryId { get; init; }
+
+ ///
+ /// Gets the path of the media library scan snapshot item.
+ ///
+ public required string Path { get; init; }
+
+ ///
+ /// Gets the hash calculated for the media library scan snapshot item.
+ ///
+ public required ulong ContentHash { get; init; }
+
+ ///
+ /// Gets the size of the media library scan snapshot item, in bytes.
+ ///
+ public required long FileSize { get; init; }
+
+ ///
+ /// Gets the time and date when the media library scan snapshot item was last modified, stored in ticks.
+ ///
+ public required long Ticks { get; init; }
+
+ ///
+ /// Gets the media library to which this media library scan snapshot item belongs.
+ ///
+ public required LibraryEntity Library { get; init; } = null!;
+
+ ///
+ /// Gets or sets the time and date when the entity was added.
+ ///
+ public required DateTime CreatedOnUtc { get; set; }
+
+ ///
+ /// Gets or sets the Id of the user that created the entity.
+ ///
+ public required Guid CreatedBy { get; set; }
+
+ ///
+ /// Gets or sets the optional time and date when the entity was updated.
+ ///
+ public DateTime? UpdatedOnUtc { get; set; }
+
+ ///
+ /// Gets or sets the optional Id of the user that updated the entity.
+ ///
+ public required Guid? UpdatedBy { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanStagingResultsEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanStagingResultsEntity.cs
new file mode 100644
index 00000000..eb77076a
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanStagingResultsEntity.cs
@@ -0,0 +1,59 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+
+///
+/// Repository entity for a media library scan staging result, holding the file system items discovered during a scan, before they are compared against the media library scan snapshot of the previous scan.
+///
+[DebuggerDisplay("Id: {Id}; Path: {Path}")]
+public class LibraryScanStagingResultsEntity : IStorageEntity
+{
+ ///
+ /// Gets the Id of the media library scan staging result.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets the Id of the media library scan that this staging result belongs to.
+ ///
+ public required Guid LibraryScanId { get; init; }
+
+ ///
+ /// Gets the path of the media library scan staging result.
+ ///
+ public required string Path { get; init; }
+
+ ///
+ /// Gets the size of the media library scan staging result, in bytes.
+ ///
+ public required long Size { get; init; }
+
+ ///
+ /// Gets the time and date when the file system item was last modified, stored in ticks.
+ ///
+ public required long Ticks { get; init; }
+
+ ///
+ /// Gets the hash calculated for the media library scan staging result.
+ ///
+ public required ulong ContentHash { get; init; }
+
+ ///
+ /// Gets the hash of the same file system item, as stored in the media library scan snapshot of a previous scan, or 0 if the file system item is new.
+ ///
+ public required ulong PreviousContentHash { get; init; }
+
+ ///
+ /// Gets whether this media library scan staging result represents a file system item that needs its content to be hashed, because it is either new, or it has changed since the previous scan.
+ ///
+ public required bool NeedsRehash { get; init; }
+
+ ///
+ /// Gets whether this media library scan staging result represents a file system item that was not present in the media library scan snapshot of a previous scan.
+ ///
+ public required bool IsNew { get; init; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRangeRepositoryAction.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRangeRepositoryAction.cs
new file mode 100644
index 00000000..9251f07d
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Common/Actions/IInsertRangeRepositoryAction.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
+
+///
+/// Interface defining the "insert range" action for interacting with a generic persistance medium.
+///
+/// The type used for the insert range action. It should implement .
+public interface IInsertRangeRepositoryAction where TModel : IStorageEntity
+{
+ ///
+ /// Saves a collection of elements of type in the storage medium.
+ ///
+ /// The elements to be saved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> InsertRangeAsync(IReadOnlyCollection entities, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/IDirectoryScanFingerprintRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/IDirectoryScanFingerprintRepository.cs
new file mode 100644
index 00000000..c075318d
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/IDirectoryScanFingerprintRepository.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
+
+///
+/// Interface for the repository for directory scan fingerprints.
+///
+public interface IDirectoryScanFingerprintRepository : IRepository
+{
+ ///
+ /// Gets the directory scan fingerprints of a media library, mapped by the directory path.
+ ///
+ /// The unique identifier of the library for which to get the directory scan fingerprints.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a path mapped dictionary of directory scan fingerprints, or an error.
+ Task>> GetMappedByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
+
+ ///
+ /// Inserts or updates the provided directory scan fingerprints in the storage medium.
+ ///
+ /// The directory scan fingerprints to insert or update.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> UpsertRangeAsync(IReadOnlyCollection entities, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanResultRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanResultRepository.cs
index 09a580be..bbc44d54 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanResultRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanResultRepository.cs
@@ -1,12 +1,7 @@
#region ========================================================================= USING =====================================================================================
-using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
@@ -17,11 +12,4 @@ namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
public interface ILibraryScanResultRepository : IRepository,
IInsertRepositoryAction
{
- ///
- /// Gets all media library scan results that belong to the last scan of a library identified by , from the storage medium.
- ///
- /// The unique identifier of the library for which to get the results of the last scans.
- /// Cancellation token that can be used to stop the execution.
- /// An containing either a path mapped dictionary of , or an error.
- Task>> GetPathMappedByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
new file mode 100644
index 00000000..b8d260c9
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
+
+///
+/// Interface for the repository for media library scan snapshots.
+///
+public interface ILibraryScanSnapshotRepository : IRepository
+{
+ ///
+ /// Gets the paths of the media library scan snapshot items that are no longer present in the current scan, meaning they were deleted from the storage medium.
+ ///
+ /// The unique identifier of the library for which to get the deleted media library scan snapshot item paths.
+ /// The unique identifier of the media library scan for which to determine the deleted media library scan snapshot item paths.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a collection of deleted media library scan snapshot item paths, or an error.
+ Task>> GetDeletedPathsAsync(Guid libraryId, Guid scanId, CancellationToken cancellationToken);
+
+ ///
+ /// Atomically applies the results of the current scan to the storage medium, by replacing the media library scan snapshot of the previous scan with the snapshot of the current scan.
+ /// The operation updates the changed media library scan snapshot items, deletes the ones that are no longer present on disk, adds audit entries for all changed, new and deleted items,
+ /// and clears the staging results of the current scan.
+ ///
+ /// The unique identifier of the library for which to apply the scan results.
+ /// The unique identifier of the media library scan whose results are applied.
+ /// The unique identifier of the user that initiated the media library scan, used for audit purposes.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> ApplySnapshotSwapAsync(Guid libraryId, Guid scanId, Guid userId, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs
new file mode 100644
index 00000000..14e22897
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs
@@ -0,0 +1,65 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using Lumina.Application.Common.Infrastructure.Models.MediaLibraryScanJobPayloads;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
+
+///
+/// Interface for the repository for media library scan staging results.
+///
+public interface ILibraryScanStagingResultsRepository : IRepository,
+ IInsertRangeRepositoryAction
+{
+ ///
+ /// Marks the media library scan staging results of the current scan by comparing them against the media library scan snapshot of a previous scan, determining which file system items
+ /// are new, which ones changed and need their content hashed, and which ones are unchanged.
+ ///
+ /// The unique identifier of the media library scan whose staging results are marked.
+ /// The unique identifier of the library whose media library scan snapshot is compared against.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> MarkChangesAgainstSnapshotAsync(Guid scanId, Guid libraryId, CancellationToken cancellationToken);
+
+ ///
+ /// Gets the number of media library scan staging results of the current scan that need their content hashed.
+ ///
+ /// The unique identifier of the media library scan whose staging results are counted.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the number of staging results that need hashing, or an error.
+ Task> GetFilesToHashCountAsync(Guid scanId, CancellationToken cancellationToken);
+
+ ///
+ /// Gets a page of the media library scan staging results that need their content hashed, ordered by path, using keyset pagination.
+ ///
+ /// The unique identifier of the media library scan whose staging results are retrieved.
+ /// The path of the last retrieved file system item, used for keyset pagination. Pass to get the first page.
+ /// The maximum number of staging results to retrieve.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a page of staging results that need hashing, or an error.
+ Task>> GetFilesToHashPageAsync(Guid scanId, string? lastPath, int pageSize, CancellationToken cancellationToken);
+
+ ///
+ /// Updates the content hashes of the provided media library scan staging results.
+ ///
+ /// The unique identifier of the media library scan whose staging results are updated.
+ /// The file system items whose content hashes are updated.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> UpdateFileHashesAsync(Guid scanId, IReadOnlyCollection hashedFiles, CancellationToken cancellationToken);
+
+ ///
+ /// Clears all the media library scan staging results of the provided media library scan from the storage medium.
+ ///
+ /// The unique identifier of the media library scan whose staging results are cleared.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> ClearForScanAsync(Guid scanId, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/ChangedFileSystemFile.cs b/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/ChangedFileSystemFile.cs
deleted file mode 100644
index 04fd1433..00000000
--- a/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/ChangedFileSystemFile.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-#region ========================================================================= USING =====================================================================================
-using System.Diagnostics;
-using System.IO;
-#endregion
-
-namespace Lumina.Application.Common.Infrastructure.Models.MediaLibraryScanJobPayloads;
-
-///
-/// Represents an item for the payload of the file hashing media library scan job.
-///
-/// The file to whom belongs.
-/// The hash of .
-[DebuggerDisplay("File: {File}; FileHash: {FileHash}")]
-public record ChangedFileSystemFile(FileInfo File, ulong FileHash);
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/HashedFileSystemFile.cs b/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/HashedFileSystemFile.cs
new file mode 100644
index 00000000..355b8b9d
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/HashedFileSystemFile.cs
@@ -0,0 +1,70 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Models.MediaLibraryScanJobPayloads;
+
+///
+/// Represents an item for the payload of the file hashing media library scan job.
+///
+[DebuggerDisplay("Path = {Path}, CurrentHash = {CurrentHash}, OldHash = {OldHash}, Ticks = {Ticks}, Size = {Size}")]
+[StructLayout(LayoutKind.Sequential)]
+public struct HashedFileSystemFile : IEquatable
+{
+ ///
+ /// The path of the file system file.
+ ///
+ public string Path { get; set; }
+
+ ///
+ /// The size of the file system file.
+ ///
+ public long Size { get; set; }
+
+ ///
+ /// The current hash obtained by sampling the file system file contents.
+ ///
+ public ulong CurrentHash { get; set; }
+
+ ///
+ /// The old hash of the file system file, stored at the previous scan.
+ ///
+ public ulong OldHash { get; set; }
+
+ ///
+ /// The time and date when the file system file was last modified, stored in ticks.
+ ///
+ public long Ticks { get; set; }
+
+ ///
+ public readonly bool Equals(HashedFileSystemFile other)
+ {
+ return Size == other.Size && CurrentHash == other.CurrentHash && OldHash == other.OldHash && Ticks == other.Ticks && Path == other.Path;
+ }
+
+ ///
+ public override readonly bool Equals(object? obj)
+ {
+ return obj is HashedFileSystemFile item && Equals(item);
+ }
+
+ ///
+ public static bool operator ==(HashedFileSystemFile left, HashedFileSystemFile right)
+ {
+ return left.Equals(right);
+ }
+
+ ///
+ public static bool operator !=(HashedFileSystemFile left, HashedFileSystemFile right)
+ {
+ return !(left == right);
+ }
+
+ ///
+ public override readonly int GetHashCode()
+ {
+ return HashCode.Combine(Size, CurrentHash, OldHash, Ticks, Path);
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Configuration/DirectoryScanFingerprintConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/DirectoryScanFingerprintConfiguration.cs
new file mode 100644
index 00000000..5b411119
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Configuration/DirectoryScanFingerprintConfiguration.cs
@@ -0,0 +1,47 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+#endregion
+
+namespace Lumina.DataAccess.Common.Configuration;
+
+///
+/// Configures the entity mapping for the entity.
+///
+public class DirectoryScanFingerprintConfiguration : IEntityTypeConfiguration
+{
+ ///
+ /// Configures the entity.
+ ///
+ /// The builder to be used to configure the entity.
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("DirectoryScanFingerprints");
+ // composite key, so that each directory scan fingerprint is uniquely identified within its library by its path
+ builder.HasKey(directoryScanFingerprint => new { directoryScanFingerprint.LibraryId, directoryScanFingerprint.Path });
+
+ // one library with many directory scan fingerprints
+ builder.HasOne()
+ .WithMany()
+ .HasForeignKey(directoryScanFingerprint => directoryScanFingerprint.LibraryId)
+ .IsRequired()
+ .OnDelete(DeleteBehavior.Cascade);
+
+ builder.Property(directoryScanFingerprint => directoryScanFingerprint.Id)
+ .ValueGeneratedNever()
+ .HasColumnOrder(0);
+
+ builder.Property(directoryScanFingerprint => directoryScanFingerprint.Path)
+ .HasMaxLength(1024)
+ .IsRequired()
+ .HasColumnOrder(1);
+
+ builder.Property(directoryScanFingerprint => directoryScanFingerprint.LastWriteTimeUtc)
+ .IsRequired()
+ .HasColumnOrder(2);
+
+ // enables fast lookups of the directory scan fingerprints of a library
+ builder.HasIndex(directoryScanFingerprint => directoryScanFingerprint.LibraryId);
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryScanConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryScanConfiguration.cs
index 6c14ad63..3765248c 100644
--- a/src/Lumina.DataAccess/Common/Configuration/LibraryScanConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryScanConfiguration.cs
@@ -57,5 +57,11 @@ public class LibraryScanConfiguration : IEntityTypeConfiguration libraryScan.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(5);
+
+ // Indexes
+
+ // enables fast lookup of latest non-running scans per library
+ builder.HasIndex(libraryScan => new { libraryScan.LibraryId, libraryScan.Status, libraryScan.CreatedOnUtc })
+ .IsDescending(true, false, true); // CreatedOnUtc DESC
}
}
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryScanResultConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryScanResultConfiguration.cs
index a4a78bd7..5f500424 100644
--- a/src/Lumina.DataAccess/Common/Configuration/LibraryScanResultConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryScanResultConfiguration.cs
@@ -18,12 +18,12 @@ public class LibraryScanResultConfiguration : IEntityTypeConfiguration builder)
{
builder.ToTable("LibraryScanResults");
- // composite key for efficient scan-specific lookups
+ // composite key for efficient scan-specific lookups (paths are enforced as UNIQUE within the same scan)
builder.HasKey(libraryScanResult => new { libraryScanResult.LibraryScanId, libraryScanResult.Path });
// one library scan with many library scan results
builder.HasOne(libraryScanResult => libraryScanResult.LibraryScan)
- .WithMany()
+ .WithMany(libraryScan => libraryScan.LibraryScanResults)
.HasForeignKey(libraryScanResult => libraryScanResult.LibraryScanId)
.IsRequired()
.OnDelete(DeleteBehavior.Cascade);
@@ -46,15 +46,19 @@ public class LibraryScanResultConfiguration : IEntityTypeConfiguration libraryScanResult.LastModified)
+ builder.Property(libraryScanResult => libraryScanResult.Ticks)
.IsRequired()
.HasColumnOrder(4);
- // Indexes
- builder.HasIndex(libraryScanResult => new { libraryScanResult.ContentHash, libraryScanResult.FileSize, libraryScanResult.Path })
- .IsUnique();
+ builder.Property(libraryScanResult => libraryScanResult.Status)
+ .IsRequired()
+ .HasConversion()
+ .HasMaxLength(10)
+ .HasColumnOrder(5);
- builder.HasIndex(libraryScanResult => libraryScanResult.Path)
- .IsUnique();
+ // Indexes
+ builder.HasIndex(libraryScanResult => new { libraryScanResult.ContentHash, libraryScanResult.FileSize, libraryScanResult.Path });
+
+ builder.HasIndex(libraryScanResult => libraryScanResult.Path);
}
}
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryScanSnapshotConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryScanSnapshotConfiguration.cs
new file mode 100644
index 00000000..756de536
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryScanSnapshotConfiguration.cs
@@ -0,0 +1,72 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+#endregion
+
+namespace Lumina.DataAccess.Common.Configuration;
+
+///
+/// Configures the entity mapping for the entity.
+///
+public class LibraryScanSnapshotConfiguration : IEntityTypeConfiguration
+{
+ ///
+ /// Configures the entity.
+ ///
+ /// The builder to be used to configure the entity.
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("LibraryScanSnapshots");
+ // composite key, so that each media library scan snapshot item is uniquely identified within its library by its path
+ builder.HasKey(libraryScanSnapshot => new { libraryScanSnapshot.LibraryId, libraryScanSnapshot.Path });
+
+ // one library with many media library scan snapshot items
+ builder.HasOne(libraryScanSnapshot => libraryScanSnapshot.Library)
+ .WithMany()
+ .HasForeignKey(libraryScanSnapshot => libraryScanSnapshot.LibraryId)
+ .IsRequired()
+ .OnDelete(DeleteBehavior.Cascade);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.Id)
+ .ValueGeneratedNever()
+ .HasColumnOrder(0);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.Path)
+ .HasMaxLength(1024)
+ .IsRequired()
+ .HasColumnOrder(1);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.ContentHash)
+ .IsRequired()
+ .HasColumnOrder(2);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.FileSize)
+ .IsRequired()
+ .HasColumnOrder(3);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.Ticks)
+ .IsRequired()
+ .HasColumnOrder(4);
+
+ // audit
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.CreatedOnUtc)
+ .IsRequired()
+ .HasColumnOrder(5);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.CreatedBy)
+ .IsRequired()
+ .HasColumnOrder(6);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.UpdatedOnUtc)
+ .HasDefaultValue(null)
+ .HasColumnOrder(7);
+
+ builder.Property(libraryScanSnapshot => libraryScanSnapshot.UpdatedBy)
+ .HasDefaultValue(null)
+ .HasColumnOrder(8);
+
+ // enables fast lookups of the media library scan snapshot items of a library
+ builder.HasIndex(libraryScanSnapshot => libraryScanSnapshot.LibraryId);
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryScanStagingResultsConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryScanStagingResultsConfiguration.cs
new file mode 100644
index 00000000..d5c13f92
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryScanStagingResultsConfiguration.cs
@@ -0,0 +1,67 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+#endregion
+
+namespace Lumina.DataAccess.Common.Configuration;
+
+///
+/// Configures the entity mapping for the entity.
+///
+public class LibraryScanStagingResultsConfiguration : IEntityTypeConfiguration
+{
+ ///
+ /// Configures the entity.
+ ///
+ /// The builder to be used to configure the entity.
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("LibraryScanStagingResults");
+ // composite key, so that each media library scan staging result is uniquely identified within its scan by its path
+ builder.HasKey(libraryScanStagingResult => new { libraryScanStagingResult.LibraryScanId, libraryScanStagingResult.Path });
+
+ // one media library scan with many media library scan staging results
+ builder.HasOne()
+ .WithMany()
+ .HasForeignKey(libraryScanStagingResult => libraryScanStagingResult.LibraryScanId)
+ .IsRequired()
+ .OnDelete(DeleteBehavior.Cascade);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.Id)
+ .ValueGeneratedNever()
+ .HasColumnOrder(0);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.Path)
+ .HasMaxLength(1024)
+ .IsRequired()
+ .HasColumnOrder(1);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.Size)
+ .IsRequired()
+ .HasColumnOrder(2);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.Ticks)
+ .IsRequired()
+ .HasColumnOrder(3);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.ContentHash)
+ .IsRequired()
+ .HasColumnOrder(4);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.PreviousContentHash)
+ .IsRequired()
+ .HasColumnOrder(5);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.NeedsRehash)
+ .IsRequired()
+ .HasColumnOrder(6);
+
+ builder.Property(libraryScanStagingResult => libraryScanStagingResult.IsNew)
+ .IsRequired()
+ .HasColumnOrder(7);
+
+ // enables fast lookups of the staging results of a scan that need their content hashed
+ builder.HasIndex(libraryScanStagingResult => new { libraryScanStagingResult.LibraryScanId, libraryScanStagingResult.NeedsRehash });
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20250302132630_AddsLibraryScanFileStatusColumn.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20250302132630_AddsLibraryScanFileStatusColumn.Designer.cs
new file mode 100644
index 00000000..8f3096da
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20250302132630_AddsLibraryScanFileStatusColumn.Designer.cs
@@ -0,0 +1,877 @@
+//
+using System;
+using Lumina.DataAccess.Core.UoW;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations
+{
+ [DbContext(typeof(LuminaDbContext))]
+ [Migration("20250302132630_AddsLibraryScanFileStatusColumn")]
+ partial class AddsLibraryScanFileStatusColumn
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("BookGenres", (string)null);
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("BookTags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("PermissionName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Permissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("RoleId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("RoleId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("UserId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("UserPermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("UserId", "RoleId")
+ .IsUnique();
+
+ b.ToTable("UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Genres", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Tags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CoverImage")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("DownloadMedatadaFromWeb")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(6);
+
+ b.Property("IsEnabled")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(4);
+
+ b.Property("IsLocked")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("LibraryType")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("SaveMetadataInMediaDirectories")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Libraries", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("LibraryScans", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b =>
+ {
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasMaxLength(24)
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("FileSize")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("LastModified")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("LibraryScanEntityId")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("LibraryScanId", "Path");
+
+ b.HasIndex("LibraryScanEntityId");
+
+ b.HasIndex("Path")
+ .IsUnique();
+
+ b.HasIndex("ContentHash", "FileSize", "Path")
+ .IsUnique();
+
+ b.ToTable("LibraryScanResults", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ASIN")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(21);
+
+ b.Property("AppleBooksId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("BarnesAndNobleId")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(28);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(33);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(32);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("Edition")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("Format")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("GoodreadsId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(22);
+
+ b.Property("GoogleBooksId")
+ .HasMaxLength(12)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(27);
+
+ b.Property("LCCN")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("LibraryThingId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(26);
+
+ b.Property("OCLCNumber")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("OpenLibraryId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("OriginalLanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("OriginalLanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("OriginalLanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("OriginalReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("OriginalReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("OriginalTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("PageCount")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(17);
+
+ b.Property("Publisher")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("ReReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("ReReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ReleaseCountry")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("ReleaseVersion")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(35);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(34);
+
+ b.Property("VolumeNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(20);
+
+ b.HasKey("Id");
+
+ b.ToTable("Books", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("TempPassword")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("TempPasswordCreated")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("TotpSecret")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("Username")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.HasKey("Id");
+
+ b.HasIndex("Username")
+ .IsUnique();
+
+ b.ToTable("Users", (string)null);
+ });
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
+ .WithMany()
+ .HasForeignKey("BookId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null)
+ .WithMany()
+ .HasForeignKey("GenreId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null)
+ .WithMany()
+ .HasForeignKey("BookId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null)
+ .WithMany()
+ .HasForeignKey("TagId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
+ .WithMany("RolePermissions")
+ .HasForeignKey("PermissionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
+ .WithMany("RolePermissions")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Permission");
+
+ b.Navigation("Role");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission")
+ .WithMany("UserPermissions")
+ .HasForeignKey("PermissionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("UserPermissions")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Permission");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithOne("UserRole")
+ .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("Libraries")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b1.Property("Path")
+ .IsRequired()
+ .HasMaxLength(260)
+ .HasColumnType("TEXT")
+ .HasColumnName("Path");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("LibraryId");
+
+ b1.ToTable("LibraryContentLocations", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("LibraryId");
+ });
+
+ b.Navigation("ContentLocations");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", "Library")
+ .WithMany("LibraryScans")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User")
+ .WithMany("LibraryScans")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b =>
+ {
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", null)
+ .WithMany("LibraryScanResults")
+ .HasForeignKey("LibraryScanEntityId");
+
+ b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", "LibraryScan")
+ .WithMany()
+ .HasForeignKey("LibraryScanId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("LibraryScan");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b1.Property("MaxValue")
+ .HasColumnType("decimal(3,2)");
+
+ b1.Property("Source")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b1.Property("Value")
+ .HasColumnType("decimal(3,2)");
+
+ b1.Property("VoteCount")
+ .HasColumnType("INTEGER");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("BookId");
+
+ b1.ToTable("BookRatings", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("BookId");
+ });
+
+ b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 =>
+ {
+ b1.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b1.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b1.Property("Format")
+ .IsRequired()
+ .HasMaxLength(6)
+ .HasColumnType("TEXT");
+
+ b1.Property("Value")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("TEXT")
+ .HasColumnName("ISBN");
+
+ b1.HasKey("Id");
+
+ b1.HasIndex("BookId");
+
+ b1.ToTable("BookISBNs", (string)null);
+
+ b1.WithOwner()
+ .HasForeignKey("BookId");
+ });
+
+ b.Navigation("ISBNs");
+
+ b.Navigation("Ratings");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Navigation("RolePermissions");
+
+ b.Navigation("UserPermissions");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Navigation("RolePermissions");
+
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Navigation("LibraryScans");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.Navigation("LibraryScanResults");
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b =>
+ {
+ b.Navigation("Libraries");
+
+ b.Navigation("LibraryScans");
+
+ b.Navigation("UserPermissions");
+
+ b.Navigation("UserRole");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20250302132630_AddsLibraryScanFileStatusColumn.cs b/src/Lumina.DataAccess/Common/Migrations/20250302132630_AddsLibraryScanFileStatusColumn.cs
new file mode 100644
index 00000000..49c17494
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20250302132630_AddsLibraryScanFileStatusColumn.cs
@@ -0,0 +1,30 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations;
+
+///
+public partial class AddsLibraryScanFileStatusColumn : Migration
+{
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Status",
+ table: "LibraryScanResults",
+ type: "TEXT",
+ maxLength: 10,
+ nullable: false,
+ defaultValue: "")
+ .Annotation("Relational:ColumnOrder", 5);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Status",
+ table: "LibraryScanResults");
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20250317192401_AddsLibraryScanResultTickColumn.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20250317192401_AddsLibraryScanResultTickColumn.Designer.cs
new file mode 100644
index 00000000..74777280
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20250317192401_AddsLibraryScanResultTickColumn.Designer.cs
@@ -0,0 +1,877 @@
+//
+using System;
+using Lumina.DataAccess.Core.UoW;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations
+{
+ [DbContext(typeof(LuminaDbContext))]
+ [Migration("20250317192401_AddsLibraryScanResultTickColumn")]
+ partial class AddsLibraryScanResultTickColumn
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "9.0.0");
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("BookGenres", (string)null);
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("BookTags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("PermissionName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Permissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("RoleId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("RoleId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("UserId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("UserPermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("UserId", "RoleId")
+ .IsUnique();
+
+ b.ToTable("UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Genres", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Tags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CoverImage")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("DownloadMedatadaFromWeb")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(6);
+
+ b.Property("IsEnabled")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(4);
+
+ b.Property("IsLocked")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("LibraryType")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("SaveMetadataInMediaDirectories")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Libraries", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("LibraryScans", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b =>
+ {
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasMaxLength(24)
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("FileSize")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("LibraryScanEntityId")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.HasKey("LibraryScanId", "Path");
+
+ b.HasIndex("LibraryScanEntityId");
+
+ b.HasIndex("Path")
+ .IsUnique();
+
+ b.HasIndex("ContentHash", "FileSize", "Path")
+ .IsUnique();
+
+ b.ToTable("LibraryScanResults", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ASIN")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(21);
+
+ b.Property("AppleBooksId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("BarnesAndNobleId")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(28);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(33);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(32);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("Edition")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("Format")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("GoodreadsId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(22);
+
+ b.Property("GoogleBooksId")
+ .HasMaxLength(12)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(27);
+
+ b.Property("LCCN")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("LibraryThingId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(26);
+
+ b.Property("OCLCNumber")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("OpenLibraryId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("OriginalLanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("OriginalLanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("OriginalLanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("OriginalReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("OriginalReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("OriginalTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("PageCount")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(17);
+
+ b.Property("Publisher")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("ReReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("ReReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ReleaseCountry")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("ReleaseVersion")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property