diff --git a/src/FilterLists.Api/Migrations/20171101011709_add License.Designer.cs b/src/FilterLists.Api/Migrations/20171101011709_add License.Designer.cs
new file mode 100644
index 000000000..7e1e89be6
--- /dev/null
+++ b/src/FilterLists.Api/Migrations/20171101011709_add License.Designer.cs
@@ -0,0 +1,340 @@
+//
+using FilterLists.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage;
+using Microsoft.EntityFrameworkCore.Storage.Internal;
+using System;
+
+namespace FilterLists.Api.Migrations
+{
+ [DbContext(typeof(FilterListsDbContext))]
+ [Migration("20171101011709_add License")]
+ partial class addLicense
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
+ .HasAnnotation("ProductVersion", "2.0.0-rtm-26452");
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Description")
+ .HasMaxLength(4096);
+
+ b.Property("DescriptionSourceUrl")
+ .HasMaxLength(2083);
+
+ b.Property("DonateUrl")
+ .HasMaxLength(2083);
+
+ b.Property("EmailAddress")
+ .HasMaxLength(126);
+
+ b.Property("ForumUrl")
+ .HasMaxLength(2083);
+
+ b.Property("HomeUrl")
+ .HasMaxLength(2083);
+
+ b.Property("IssuesUrl")
+ .HasMaxLength(2083);
+
+ b.Property("LicenseId");
+
+ b.Property("MaintainerId");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(126);
+
+ b.Property("ViewUrl")
+ .HasMaxLength(2083);
+
+ b.HasKey("Id");
+
+ b.HasIndex("LicenseId");
+
+ b.HasIndex("MaintainerId");
+
+ b.ToTable("filterlists");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterListLanguage", b =>
+ {
+ b.Property("FilterListId");
+
+ b.Property("LanguageId");
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.HasKey("FilterListId", "LanguageId");
+
+ b.HasIndex("LanguageId");
+
+ b.ToTable("filterlists_languages");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterListRule", b =>
+ {
+ b.Property("FilterListId");
+
+ b.Property("RuleId");
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.HasKey("FilterListId", "RuleId");
+
+ b.HasIndex("RuleId");
+
+ b.ToTable("filterlists_rules");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterListSoftware", b =>
+ {
+ b.Property("FilterListId");
+
+ b.Property("SoftwareId");
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.HasKey("FilterListId", "SoftwareId");
+
+ b.HasIndex("SoftwareId");
+
+ b.ToTable("filterlists_software");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.Language", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Iso6391")
+ .HasMaxLength(2);
+
+ b.Property("Iso6392")
+ .HasMaxLength(3);
+
+ b.Property("Iso6392B")
+ .HasMaxLength(3);
+
+ b.Property("Iso6392T")
+ .HasMaxLength(3);
+
+ b.Property("Iso6393")
+ .HasMaxLength(3);
+
+ b.Property("LocalName")
+ .HasMaxLength(126);
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Name")
+ .HasMaxLength(126);
+
+ b.HasKey("Id");
+
+ b.ToTable("languages");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.License", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("DescriptionUrl")
+ .HasMaxLength(2083);
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(126);
+
+ b.Property("PermissiveRedistribution");
+
+ b.Property("PermissiveUsage");
+
+ b.HasKey("Id");
+
+ b.ToTable("licenses");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("EmailAddress")
+ .HasMaxLength(126);
+
+ b.Property("HomeUrl")
+ .HasMaxLength(2083);
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(126);
+
+ b.Property("TwitterHandle")
+ .HasMaxLength(126);
+
+ b.HasKey("Id");
+
+ b.ToTable("maintainers");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.Rule", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Raw")
+ .HasMaxLength(2083);
+
+ b.HasKey("Id");
+
+ b.ToTable("rules");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.Software", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("DownloadUrl")
+ .HasMaxLength(2083);
+
+ b.Property("HomeUrl")
+ .HasMaxLength(2083);
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Name")
+ .HasMaxLength(126);
+
+ b.HasKey("Id");
+
+ b.ToTable("software");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
+ {
+ b.HasOne("FilterLists.Data.Entities.License")
+ .WithMany("FilterLists")
+ .HasForeignKey("LicenseId");
+
+ b.HasOne("FilterLists.Data.Entities.Maintainer")
+ .WithMany("FilterLists")
+ .HasForeignKey("MaintainerId");
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterListLanguage", b =>
+ {
+ b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
+ .WithMany("FilterListLanguages")
+ .HasForeignKey("FilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.Language", "Language")
+ .WithMany("FilterListLanguages")
+ .HasForeignKey("LanguageId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterListRule", b =>
+ {
+ b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
+ .WithMany("FilterListRules")
+ .HasForeignKey("FilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.Rule", "Rule")
+ .WithMany("FilterListRules")
+ .HasForeignKey("RuleId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.FilterListSoftware", b =>
+ {
+ b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
+ .WithMany("FilterListSoftware")
+ .HasForeignKey("FilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.Software", "Software")
+ .WithMany("FilterListSoftware")
+ .HasForeignKey("SoftwareId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/FilterLists.Api/Migrations/20171101011709_add License.cs b/src/FilterLists.Api/Migrations/20171101011709_add License.cs
new file mode 100644
index 000000000..72e002fec
--- /dev/null
+++ b/src/FilterLists.Api/Migrations/20171101011709_add License.cs
@@ -0,0 +1,69 @@
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using System;
+using System.Collections.Generic;
+
+namespace FilterLists.Api.Migrations
+{
+ public partial class addLicense : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "LicenseId",
+ table: "filterlists",
+ type: "int",
+ nullable: true);
+
+ migrationBuilder.CreateTable(
+ name: "licenses",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ CreatedDateUtc = table.Column(type: "TIMESTAMP", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ DescriptionUrl = table.Column(type: "varchar(2083)", maxLength: 2083, nullable: true),
+ ModifiedDateUtc = table.Column(type: "TIMESTAMP", nullable: false),
+ Name = table.Column(type: "varchar(126)", maxLength: 126, nullable: false),
+ PermissiveRedistribution = table.Column(type: "bit", nullable: false),
+ PermissiveUsage = table.Column(type: "bit", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_licenses", x => x.Id);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_filterlists_LicenseId",
+ table: "filterlists",
+ column: "LicenseId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_filterlists_licenses_LicenseId",
+ table: "filterlists",
+ column: "LicenseId",
+ principalTable: "licenses",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_filterlists_licenses_LicenseId",
+ table: "filterlists");
+
+ migrationBuilder.DropTable(
+ name: "licenses");
+
+ migrationBuilder.DropIndex(
+ name: "IX_filterlists_LicenseId",
+ table: "filterlists");
+
+ migrationBuilder.DropColumn(
+ name: "LicenseId",
+ table: "filterlists");
+ }
+ }
+}
diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
index 47db678d7..cda38db41 100644
--- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
+++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
@@ -50,6 +50,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property("IssuesUrl")
.HasMaxLength(2083);
+ b.Property("LicenseId");
+
b.Property("MaintainerId");
b.Property("ModifiedDateUtc")
@@ -65,6 +67,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("Id");
+ b.HasIndex("LicenseId");
+
b.HasIndex("MaintainerId");
b.ToTable("filterlists");
@@ -172,6 +176,35 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("languages");
});
+ modelBuilder.Entity("FilterLists.Data.Entities.License", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("DescriptionUrl")
+ .HasMaxLength(2083);
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(126);
+
+ b.Property("PermissiveRedistribution");
+
+ b.Property("PermissiveUsage");
+
+ b.HasKey("Id");
+
+ b.ToTable("licenses");
+ });
+
modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b =>
{
b.Property("Id")
@@ -253,6 +286,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
{
+ b.HasOne("FilterLists.Data.Entities.License")
+ .WithMany("FilterLists")
+ .HasForeignKey("LicenseId");
+
b.HasOne("FilterLists.Data.Entities.Maintainer")
.WithMany("FilterLists")
.HasForeignKey("MaintainerId");
diff --git a/src/FilterLists.Data/Entities/FilterList.cs b/src/FilterLists.Data/Entities/FilterList.cs
index f24ef70d7..7664dc43b 100644
--- a/src/FilterLists.Data/Entities/FilterList.cs
+++ b/src/FilterLists.Data/Entities/FilterList.cs
@@ -14,6 +14,7 @@ public class FilterList : BaseEntity
public ICollection FilterListLanguages { get; set; }
public ICollection FilterListRules { get; set; }
public ICollection FilterListSoftware { get; set; }
+ public int? LicenseId { get; set; }
public int? MaintainerId { get; set; }
public string Name { get; set; }
public string ViewUrl { get; set; }
diff --git a/src/FilterLists.Data/Entities/License.cs b/src/FilterLists.Data/Entities/License.cs
new file mode 100644
index 000000000..95ae9e8b9
--- /dev/null
+++ b/src/FilterLists.Data/Entities/License.cs
@@ -0,0 +1,13 @@
+using System.Collections.Generic;
+
+namespace FilterLists.Data.Entities
+{
+ public class License : BaseEntity
+ {
+ public string DescriptionUrl { get; set; }
+ public ICollection FilterLists { get; set; }
+ public string Name { get; set; }
+ public bool PermissiveRedistribution { get; set; }
+ public bool PermissiveUsage { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs
new file mode 100644
index 000000000..b089bdd1d
--- /dev/null
+++ b/src/FilterLists.Data/EntityTypeConfigurations/LicenseTypeConfiguration.cs
@@ -0,0 +1,20 @@
+using FilterLists.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace FilterLists.Data.EntityTypeConfigurations
+{
+ public class LicenseTypeConfiguration : BaseEntityTypeConfiguration
+ {
+ public override void Configure(EntityTypeBuilder entityTypeBuilder)
+ {
+ entityTypeBuilder.ToTable("licenses");
+ entityTypeBuilder.Property(b => b.DescriptionUrl)
+ .HasMaxLength(2083);
+ entityTypeBuilder.Property(b => b.Name)
+ .IsRequired()
+ .HasMaxLength(126);
+ base.Configure(entityTypeBuilder);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FilterLists.Data/FilterListsDbContext.cs b/src/FilterLists.Data/FilterListsDbContext.cs
index c19da8322..988cf2de7 100644
--- a/src/FilterLists.Data/FilterListsDbContext.cs
+++ b/src/FilterLists.Data/FilterListsDbContext.cs
@@ -13,6 +13,7 @@ public FilterListsDbContext(DbContextOptions options)
public DbSet FilterLists { get; set; }
public DbSet Languages { get; set; }
+ public DbSet Licenses { get; set; }
public DbSet Maintainers { get; set; }
public DbSet Rules { get; set; }
public DbSet Software { get; set; }
@@ -21,6 +22,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new FilterListTypeConfiguration());
modelBuilder.ApplyConfiguration(new LanguageTypeConfiguration());
+ modelBuilder.ApplyConfiguration(new LicenseTypeConfiguration());
modelBuilder.ApplyConfiguration(new MaintainerTypeConfiguration());
modelBuilder.ApplyConfiguration(new RuleTypeConfiguration());
modelBuilder.ApplyConfiguration(new SoftwareTypeConfiguration());