diff --git a/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs index 7a05c717e..d56b42220 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/BaseEntityConfiguration.cs @@ -1,7 +1,6 @@ using FilterLists.Data.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Newtonsoft.Json; namespace FilterLists.Data.EntityTypeConfigurations { @@ -12,16 +11,13 @@ public virtual void Configure(EntityTypeBuilder entityTypeBuilder) entityTypeBuilder.HasKey(b => b.Id); entityTypeBuilder.Property(b => b.Id) - .HasAnnotation("JsonIgnore", new JsonIgnoreAttribute()) .ValueGeneratedOnAdd(); entityTypeBuilder.Property(b => b.CreatedDateUtc) - .HasAnnotation("JsonIgnore", new JsonIgnoreAttribute()) .HasColumnType("TIMESTAMP") .ValueGeneratedOnAdd(); entityTypeBuilder.Property(b => b.ModifiedDateUtc) - .HasAnnotation("JsonIgnore", new JsonIgnoreAttribute()) .HasColumnType("TIMESTAMP") .ValueGeneratedOnUpdate(); } diff --git a/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs index 82fca8f9e..be494ab3d 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/FilterListTypeConfiguration.cs @@ -1,8 +1,5 @@ -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using FilterLists.Data.Entities; +using FilterLists.Data.Entities; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Newtonsoft.Json; namespace FilterLists.Data.EntityTypeConfigurations { @@ -10,66 +7,32 @@ public class FilterListTypeConfiguration : BaseEntityTypeConfiguration entityTypeBuilder) { - entityTypeBuilder.Property(b => b.MaintainerId) - .HasAnnotation("JsonIgnore", new JsonIgnoreAttribute()); - entityTypeBuilder.Property(b => b.Description) - .HasAnnotation("Description", - new DescriptionAttribute( - "A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor.")) .HasMaxLength(1022); entityTypeBuilder.Property(b => b.DescriptionSourceUrl) - .HasAnnotation("Description", - new DescriptionAttribute( - "The URL to the list's documentation page from which the description was quoted if applicable.")) - .HasAnnotation("Url", new UrlAttribute()) .HasMaxLength(2083); entityTypeBuilder.Property(b => b.DonateUrl) - .HasAnnotation("Description", - new DescriptionAttribute( - "The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud.")) - .HasAnnotation("Url", new UrlAttribute()) .HasMaxLength(2083); entityTypeBuilder.Property(b => b.EmailAddress) - .HasAnnotation("Description", - new DescriptionAttribute("The email address for communicating issues or comments about the list.")) - .HasAnnotation("EmailAddress", new EmailAddressAttribute()) .HasMaxLength(126); entityTypeBuilder.Property(b => b.ForumUrl) - .HasAnnotation("Description", - new DescriptionAttribute( - "The URL to the list's forum where issues, change requests, etc. are discussed.")) - .HasAnnotation("Url", new UrlAttribute()) .HasMaxLength(2083); entityTypeBuilder.Property(b => b.HomeUrl) - .HasAnnotation("Description", - new DescriptionAttribute( - "The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list.")) - .HasAnnotation("Url", new UrlAttribute()) .HasMaxLength(2083); entityTypeBuilder.Property(b => b.IssuesUrl) - .HasAnnotation("Description", new DescriptionAttribute("The URL to the list's GitHub Issues.")) - .HasAnnotation("Url", new UrlAttribute()) .HasMaxLength(2083); entityTypeBuilder.Property(b => b.Name) - .HasAnnotation("Description", - new DescriptionAttribute("The name of the list as stated by the list maintainer(s) in title case.")) .IsRequired() .HasMaxLength(126); - entityTypeBuilder.Property(b => b.IssuesUrl) - .HasAnnotation("Description", - new DescriptionAttribute( - "The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.")) - .IsRequired() - .HasAnnotation("Url", new UrlAttribute()) + entityTypeBuilder.Property(b => b.ViewUrl) .HasMaxLength(2083); base.Configure(entityTypeBuilder); diff --git a/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs index d7d531f5f..0a4999f30 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/MaintainerTypeConfiguration.cs @@ -1,6 +1,4 @@ -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using FilterLists.Data.Entities; +using FilterLists.Data.Entities; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace FilterLists.Data.EntityTypeConfigurations @@ -10,22 +8,16 @@ public class MaintainerTypeConfiguration : BaseEntityTypeConfiguration entityTypeBuilder) { entityTypeBuilder.Property(b => b.Email) - .HasAnnotation("Description", new DescriptionAttribute("The email address of the list maintainer.")) - .HasAnnotation("EmailAddress", new EmailAddressAttribute()) .HasMaxLength(126); entityTypeBuilder.Property(b => b.HomeUrl) - .HasAnnotation("Description", new DescriptionAttribute("The URL to the list maintainer's home page.")) - .HasAnnotation("Url", new UrlAttribute()) .HasMaxLength(2083); entityTypeBuilder.Property(b => b.Name) - .HasAnnotation("Description", new DescriptionAttribute("The name of the list maintainer.")) .IsRequired() .HasMaxLength(126); entityTypeBuilder.Property(b => b.TwitterHandle) - .HasAnnotation("Description", new DescriptionAttribute("The Twitter handle of the list maintainer.")) .HasMaxLength(126); base.Configure(entityTypeBuilder); diff --git a/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs b/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs index 1cae2bbd7..944032645 100644 --- a/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs +++ b/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs @@ -16,7 +16,8 @@ public static void AddFilterListsServices(this IServiceCollection services, ICon { services.AddSingleton(c => configuration); services.AddEntityFrameworkMySql().AddDbContextPool(options => - options.UseMySql(configuration.GetConnectionString("FilterListsConnection"))); + options.UseMySql(configuration.GetConnectionString("FilterListsConnection"), + b => b.MigrationsAssembly("FilterLists.Api"))); services.TryAddScoped(); services.TryAddScoped(); }