diff --git a/src/FilterLists.Api/Migrations/20171101113123_add Fork.Designer.cs b/src/FilterLists.Api/Migrations/20171101113123_add Fork.Designer.cs
new file mode 100644
index 000000000..3998bfc4b
--- /dev/null
+++ b/src/FilterLists.Api/Migrations/20171101113123_add Fork.Designer.cs
@@ -0,0 +1,377 @@
+//
+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("20171101113123_add Fork")]
+ partial class addFork
+ {
+ 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("SubmissionUrl")
+ .HasMaxLength(2083);
+
+ 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.Fork", b =>
+ {
+ b.Property("ForkFilterListId");
+
+ b.Property("UpstreamFilterListId");
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.HasKey("ForkFilterListId", "UpstreamFilterListId");
+
+ b.HasIndex("UpstreamFilterListId");
+
+ b.ToTable("forks");
+ });
+
+ 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("PermissiveAdaptation");
+
+ b.Property("PermissiveCommercial");
+
+ 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);
+ });
+
+ modelBuilder.Entity("FilterLists.Data.Entities.Fork", b =>
+ {
+ b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList")
+ .WithMany()
+ .HasForeignKey("ForkFilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList")
+ .WithMany()
+ .HasForeignKey("UpstreamFilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/FilterLists.Api/Migrations/20171101113123_add Fork.cs b/src/FilterLists.Api/Migrations/20171101113123_add Fork.cs
new file mode 100644
index 000000000..b4771323e
--- /dev/null
+++ b/src/FilterLists.Api/Migrations/20171101113123_add Fork.cs
@@ -0,0 +1,51 @@
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using System;
+using System.Collections.Generic;
+
+namespace FilterLists.Api.Migrations
+{
+ public partial class addFork : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "forks",
+ columns: table => new
+ {
+ ForkFilterListId = table.Column(type: "int", nullable: false),
+ UpstreamFilterListId = table.Column(type: "int", nullable: false),
+ CreatedDateUtc = table.Column(type: "TIMESTAMP", nullable: false)
+ .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
+ ModifiedDateUtc = table.Column(type: "TIMESTAMP", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_forks", x => new { x.ForkFilterListId, x.UpstreamFilterListId });
+ table.ForeignKey(
+ name: "FK_forks_filterlists_ForkFilterListId",
+ column: x => x.ForkFilterListId,
+ principalTable: "filterlists",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_forks_filterlists_UpstreamFilterListId",
+ column: x => x.UpstreamFilterListId,
+ principalTable: "filterlists",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_forks_UpstreamFilterListId",
+ table: "forks",
+ column: "UpstreamFilterListId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "forks");
+ }
+ }
+}
diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
index d90fc1ae0..b79fa5bff 100644
--- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
+++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
@@ -140,6 +140,27 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("filterlists_software");
});
+ modelBuilder.Entity("FilterLists.Data.Entities.Fork", b =>
+ {
+ b.Property("ForkFilterListId");
+
+ b.Property("UpstreamFilterListId");
+
+ b.Property("CreatedDateUtc")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TIMESTAMP");
+
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
+
+ b.HasKey("ForkFilterListId", "UpstreamFilterListId");
+
+ b.HasIndex("UpstreamFilterListId");
+
+ b.ToTable("forks");
+ });
+
modelBuilder.Entity("FilterLists.Data.Entities.Language", b =>
{
b.Property("Id")
@@ -336,6 +357,19 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasForeignKey("SoftwareId")
.OnDelete(DeleteBehavior.Cascade);
});
+
+ modelBuilder.Entity("FilterLists.Data.Entities.Fork", b =>
+ {
+ b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList")
+ .WithMany()
+ .HasForeignKey("ForkFilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList")
+ .WithMany()
+ .HasForeignKey("UpstreamFilterListId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
#pragma warning restore 612, 618
}
}
diff --git a/src/FilterLists.Data/Entities/Fork.cs b/src/FilterLists.Data/Entities/Fork.cs
new file mode 100644
index 000000000..c00943e37
--- /dev/null
+++ b/src/FilterLists.Data/Entities/Fork.cs
@@ -0,0 +1,11 @@
+namespace FilterLists.Data.Entities
+{
+ public class Fork : BaseEntity
+ {
+ public int ForkFilterListId { get; set; }
+ public FilterList ForkFilterList { get; set; }
+
+ public int UpstreamFilterListId { get; set; }
+ public FilterList UpstreamFilterList { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/ForkTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/ForkTypeConfiguration.cs
new file mode 100644
index 000000000..dfd37b25d
--- /dev/null
+++ b/src/FilterLists.Data/EntityTypeConfigurations/ForkTypeConfiguration.cs
@@ -0,0 +1,20 @@
+using FilterLists.Data.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace FilterLists.Data.EntityTypeConfigurations
+{
+ public class ForkTypeConfiguration : BaseEntityTypeConfiguration
+ {
+ public override void Configure(EntityTypeBuilder entityTypeBuilder)
+ {
+ entityTypeBuilder.ToTable("forks");
+ entityTypeBuilder.HasKey(x => new {x.ForkFilterListId, x.UpstreamFilterListId});
+ //https://stackoverflow.com/questions/47053627/configure-foreign-keys-to-the-same-entity-in-junction-entity-via-fluent-api-in-i
+ //TODO: Configure foreign key mapping from ForkFilterListId to FilterList.Id
+ //TODO: Configure foreign key mapping from UpstreamFilterListId to FilterList.Id
+ entityTypeBuilder.Ignore(x => x.Id);
+ base.Configure(entityTypeBuilder);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FilterLists.Data/FilterListsDbContext.cs b/src/FilterLists.Data/FilterListsDbContext.cs
index 988cf2de7..5ac0d552d 100644
--- a/src/FilterLists.Data/FilterListsDbContext.cs
+++ b/src/FilterLists.Data/FilterListsDbContext.cs
@@ -30,6 +30,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.ApplyConfiguration(new FilterListLanguageTypeConfiguration());
modelBuilder.ApplyConfiguration(new FilterListRuleTypeConfiguration());
modelBuilder.ApplyConfiguration(new FilterListSoftwareTypeConfiguration());
+ modelBuilder.ApplyConfiguration(new ForkTypeConfiguration());
base.OnModelCreating(modelBuilder);
}