mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds persistence for plugins and library metadata provider configurations
This commit is contained in:
1 parent
f33817f2d2
commit
f71e72a948
16 files changed
+3381
No files matched your search
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="LibraryMetadataProviderConfigurationEntity"/> entity.
|
||||
/// </summary>
|
||||
public class LibraryMetadataProviderConfigurationConfiguration : IEntityTypeConfiguration<LibraryMetadataProviderConfigurationEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="LibraryMetadataProviderConfigurationEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<LibraryMetadataProviderConfigurationEntity> builder)
|
||||
{
|
||||
builder.ToTable("LibraryMetadataProviderConfigurations");
|
||||
builder.HasKey(configuration => configuration.Id);
|
||||
builder.Property(configuration => configuration.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(configuration => configuration.LibraryId)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(1);
|
||||
builder.Property(configuration => configuration.PluginId)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(2);
|
||||
builder.Property(configuration => configuration.IsEnabled)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
builder.Property(configuration => configuration.Rank)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
// audit
|
||||
builder.Property(configuration => configuration.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
|
||||
builder.Property(configuration => configuration.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(6);
|
||||
|
||||
builder.Property(configuration => configuration.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(7);
|
||||
|
||||
builder.Property(configuration => configuration.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(8);
|
||||
|
||||
builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the entity mapping for the <see cref="PluginEntity"/> entity.
|
||||
/// </summary>
|
||||
public class PluginConfiguration : IEntityTypeConfiguration<PluginEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the <see cref="PluginEntity"/> entity.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder to be used to configure the entity.</param>
|
||||
public void Configure(EntityTypeBuilder<PluginEntity> builder)
|
||||
{
|
||||
builder.ToTable("Plugins");
|
||||
builder.HasKey(plugin => plugin.Id);
|
||||
builder.Property(plugin => plugin.Id)
|
||||
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
|
||||
.HasColumnOrder(0);
|
||||
builder.Property(plugin => plugin.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnOrder(1);
|
||||
builder.Property(plugin => plugin.Author)
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnOrder(2);
|
||||
builder.Property(plugin => plugin.Version)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnOrder(3);
|
||||
builder.Property(plugin => plugin.Description)
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnOrder(4);
|
||||
builder.Property(plugin => plugin.LoadStatus)
|
||||
.HasConversion<string>()
|
||||
.HasMaxLength(20)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(5);
|
||||
builder.Property(plugin => plugin.LoadError)
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnOrder(6);
|
||||
builder.Property(plugin => plugin.SettingsJson)
|
||||
.HasColumnOrder(7);
|
||||
builder.Property(plugin => plugin.CreatedOnUtc)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(8);
|
||||
|
||||
// audit
|
||||
builder.Property(plugin => plugin.CreatedBy)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(9);
|
||||
|
||||
builder.Property(plugin => plugin.UpdatedOnUtc)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(10);
|
||||
|
||||
builder.Property(plugin => plugin.UpdatedBy)
|
||||
.HasDefaultValue(null)
|
||||
.HasColumnOrder(11);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user