diff --git a/src/FilterLists.Api/Migrations/20180208153839_InitialCreate.Designer.cs b/src/FilterLists.Api/Migrations/20180208153839_InitialCreate.Designer.cs
deleted file mode 100644
index 3bdf95edf..000000000
--- a/src/FilterLists.Api/Migrations/20180208153839_InitialCreate.Designer.cs
+++ /dev/null
@@ -1,505 +0,0 @@
-//
-
-using System;
-using FilterLists.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace FilterLists.Api.Migrations
-{
- [DbContext(typeof(FilterListsDbContext))]
- [Migration("20180208153839_InitialCreate")]
- partial class InitialCreate
- {
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
- .HasAnnotation("ProductVersion", "2.0.1-rtm-125");
-
- modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("SMALLINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Description")
- .HasColumnType("TEXT");
-
- b.Property("DescriptionSourceUrl")
- .HasColumnType("TEXT");
-
- b.Property("DiscontinuedDate");
-
- b.Property("DonateUrl")
- .HasColumnType("TEXT");
-
- b.Property("EmailAddress")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(126)")
- .HasDefaultValueSql("NULL");
-
- b.Property("ForumUrl")
- .HasColumnType("TEXT");
-
- b.Property("HomeUrl")
- .HasColumnType("TEXT");
-
- b.Property("IssuesUrl")
- .HasColumnType("TEXT");
-
- b.Property("LicenseId");
-
- b.Property("ModifiedDateUtc")
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("VARCHAR(126)");
-
- b.Property("PolicyUrl")
- .HasColumnType("TEXT");
-
- b.Property("SubmissionUrl")
- .HasColumnType("TEXT");
-
- b.Property("SyntaxId");
-
- b.Property("ViewUrl")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("LicenseId");
-
- b.HasIndex("SyntaxId");
-
- b.ToTable("filterlists");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListLanguage", b =>
- {
- b.Property("FilterListId");
-
- b.Property("LanguageId");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.HasKey("FilterListId", "LanguageId");
-
- b.HasIndex("LanguageId", "FilterListId");
-
- b.ToTable("filterlists_languages");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.FilterListMaintainer", b =>
- {
- b.Property("FilterListId");
-
- b.Property("MaintainerId");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.HasKey("FilterListId", "MaintainerId");
-
- b.HasIndex("MaintainerId", "FilterListId");
-
- b.ToTable("filterlists_maintainers");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b =>
- {
- b.Property("ForkFilterListId");
-
- b.Property("UpstreamFilterListId");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.HasKey("ForkFilterListId", "UpstreamFilterListId");
-
- b.HasIndex("UpstreamFilterListId", "ForkFilterListId");
-
- b.ToTable("forks");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b =>
- {
- b.Property("MergeFilterListId");
-
- b.Property("UpstreamFilterListId");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.HasKey("MergeFilterListId", "UpstreamFilterListId");
-
- b.HasIndex("UpstreamFilterListId", "MergeFilterListId");
-
- b.ToTable("merges");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b =>
- {
- b.Property("SnapshotId");
-
- b.Property("RuleId");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.HasKey("SnapshotId", "RuleId");
-
- b.HasIndex("RuleId", "SnapshotId");
-
- b.ToTable("snapshots_rules");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b =>
- {
- b.Property("SyntaxId");
-
- b.Property("SoftwareId");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.HasKey("SyntaxId", "SoftwareId");
-
- b.HasIndex("SoftwareId", "SyntaxId");
-
- b.ToTable("software_syntaxes");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Language", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("SMALLINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Iso6391")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(2)")
- .HasDefaultValueSql("NULL");
-
- b.Property("Iso6392")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(3)")
- .HasDefaultValueSql("NULL");
-
- b.Property("Iso6392B")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(3)")
- .HasDefaultValueSql("NULL");
-
- b.Property("Iso6392T")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(3)")
- .HasDefaultValueSql("NULL");
-
- b.Property("Iso6393")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(3)")
- .HasDefaultValueSql("NULL");
-
- b.Property("LocalName")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(126)")
- .HasDefaultValueSql("NULL");
-
- b.Property("ModifiedDateUtc")
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Name")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(126)")
- .HasDefaultValueSql("NULL");
-
- b.HasKey("Id");
-
- b.ToTable("languages");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.License", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TINYINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("DescriptionUrl")
- .HasColumnType("TEXT");
-
- b.Property("ModifiedDateUtc")
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("VARCHAR(126)");
-
- b.Property("PermissiveAdaptation");
-
- b.Property("PermissiveCommercial");
-
- b.HasKey("Id");
-
- b.ToTable("licenses");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Maintainer", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("SMALLINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("EmailAddress")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(126)")
- .HasDefaultValueSql("NULL");
-
- b.Property("HomeUrl")
- .HasColumnType("TEXT");
-
- b.Property("ModifiedDateUtc")
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("VARCHAR(126)");
-
- b.Property("TwitterHandle")
- .ValueGeneratedOnAdd()
- .HasColumnType("VARCHAR(126)")
- .HasDefaultValueSql("NULL");
-
- b.HasKey("Id");
-
- b.ToTable("maintainers");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Rule", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Raw")
- .IsRequired()
- .HasColumnType("VARCHAR(8192)");
-
- b.HasKey("Id");
-
- b.ToTable("rules");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("MEDIUMINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("FilterListId");
-
- b.Property("HttpStatusCode")
- .HasColumnType("SMALLINT UNSIGNED");
-
- b.HasKey("Id");
-
- b.HasIndex("FilterListId");
-
- b.ToTable("snapshots");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Software", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TINYINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("DownloadUrl")
- .HasColumnType("TEXT");
-
- b.Property("HomeUrl")
- .HasColumnType("TEXT");
-
- b.Property("ModifiedDateUtc")
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("VARCHAR(126)");
-
- b.HasKey("Id");
-
- b.ToTable("software");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Syntax", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TINYINT UNSIGNED");
-
- b.Property("CreatedDateUtc")
- .ValueGeneratedOnAdd()
- .HasColumnType("TIMESTAMP");
-
- b.Property("DefinitionUrl")
- .HasColumnType("TEXT");
-
- b.Property("ModifiedDateUtc")
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("TIMESTAMP");
-
- b.Property("Name")
- .IsRequired()
- .HasColumnType("VARCHAR(126)");
-
- b.HasKey("Id");
-
- b.ToTable("syntaxes");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.FilterList", b =>
- {
- b.HasOne("FilterLists.Data.Entities.License", "License")
- .WithMany("FilterLists")
- .HasForeignKey("LicenseId");
-
- b.HasOne("FilterLists.Data.Entities.Syntax", "Syntax")
- .WithMany("FilterLists")
- .HasForeignKey("SyntaxId");
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.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.Junctions.FilterListMaintainer", b =>
- {
- b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
- .WithMany("FilterListMaintainers")
- .HasForeignKey("FilterListId")
- .OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.Maintainer", "Maintainer")
- .WithMany("FilterListMaintainers")
- .HasForeignKey("MaintainerId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Fork", b =>
- {
- b.HasOne("FilterLists.Data.Entities.FilterList", "ForkFilterList")
- .WithMany("ForkFilterLists")
- .HasForeignKey("ForkFilterListId")
- .OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList")
- .WithMany("UpstreamForkFilterLists")
- .HasForeignKey("UpstreamFilterListId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.Merge", b =>
- {
- b.HasOne("FilterLists.Data.Entities.FilterList", "MergeFilterList")
- .WithMany("MergeFilterLists")
- .HasForeignKey("MergeFilterListId")
- .OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.FilterList", "UpstreamFilterList")
- .WithMany("UpstreamMergeFilterLists")
- .HasForeignKey("UpstreamFilterListId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b =>
- {
- b.HasOne("FilterLists.Data.Entities.Rule", "Rule")
- .WithMany("SnapshotRules")
- .HasForeignKey("RuleId")
- .OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.Snapshot", "Snapshot")
- .WithMany("SnapshotRules")
- .HasForeignKey("SnapshotId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b =>
- {
- b.HasOne("FilterLists.Data.Entities.Software", "Software")
- .WithMany("SoftwareSyntaxes")
- .HasForeignKey("SoftwareId")
- .OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.Syntax", "Syntax")
- .WithMany("SoftwareSyntaxes")
- .HasForeignKey("SyntaxId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("FilterLists.Data.Entities.Snapshot", b =>
- {
- b.HasOne("FilterLists.Data.Entities.FilterList", "FilterList")
- .WithMany("Snapshots")
- .HasForeignKey("FilterListId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-#pragma warning restore 612, 618
- }
- }
-}
\ No newline at end of file
diff --git a/src/FilterLists.Api/Migrations/20180209190024_ConvertHttpStatusCodeToVarchar.cs b/src/FilterLists.Api/Migrations/20180209190024_ConvertHttpStatusCodeToVarchar.cs
deleted file mode 100644
index bee88e625..000000000
--- a/src/FilterLists.Api/Migrations/20180209190024_ConvertHttpStatusCodeToVarchar.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace FilterLists.Api.Migrations
-{
- public partial class ConvertHttpStatusCodeToVarchar : Migration
- {
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn(
- "HttpStatusCode",
- "snapshots",
- "VARCHAR(3)",
- nullable: true,
- defaultValueSql: "NULL",
- oldClrType: typeof(int),
- oldType: "SMALLINT UNSIGNED",
- oldNullable: true);
- }
-
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn(
- "HttpStatusCode",
- "snapshots",
- "SMALLINT UNSIGNED",
- nullable: true,
- oldClrType: typeof(string),
- oldType: "VARCHAR(3)",
- oldNullable: true,
- oldDefaultValueSql: "NULL");
- }
- }
-}
\ No newline at end of file
diff --git a/src/FilterLists.Api/Migrations/20180209190024_ConvertHttpStatusCodeToVarchar.Designer.cs b/src/FilterLists.Api/Migrations/20180210130730_InitialCreate.Designer.cs
similarity index 93%
rename from src/FilterLists.Api/Migrations/20180209190024_ConvertHttpStatusCodeToVarchar.Designer.cs
rename to src/FilterLists.Api/Migrations/20180210130730_InitialCreate.Designer.cs
index 7f85319bf..92c1188ae 100644
--- a/src/FilterLists.Api/Migrations/20180209190024_ConvertHttpStatusCodeToVarchar.Designer.cs
+++ b/src/FilterLists.Api/Migrations/20180210130730_InitialCreate.Designer.cs
@@ -10,8 +10,8 @@
namespace FilterLists.Api.Migrations
{
[DbContext(typeof(FilterListsDbContext))]
- [Migration("20180209190024_ConvertHttpStatusCodeToVarchar")]
- partial class ConvertHttpStatusCodeToVarchar
+ [Migration("20180210130730_InitialCreate")]
+ partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -97,7 +97,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "LanguageId");
- b.HasIndex("LanguageId", "FilterListId");
+ b.HasIndex("LanguageId");
b.ToTable("filterlists_languages");
});
@@ -114,7 +114,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "MaintainerId");
- b.HasIndex("MaintainerId", "FilterListId");
+ b.HasIndex("MaintainerId");
b.ToTable("filterlists_maintainers");
});
@@ -131,7 +131,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("ForkFilterListId", "UpstreamFilterListId");
- b.HasIndex("UpstreamFilterListId", "ForkFilterListId");
+ b.HasIndex("UpstreamFilterListId");
b.ToTable("forks");
});
@@ -148,14 +148,14 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("MergeFilterListId", "UpstreamFilterListId");
- b.HasIndex("UpstreamFilterListId", "MergeFilterListId");
+ b.HasIndex("UpstreamFilterListId");
b.ToTable("merges");
});
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b =>
{
- b.Property("SnapshotId");
+ b.Property("AddedBySnapshotId");
b.Property("RuleId");
@@ -163,9 +163,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
- b.HasKey("SnapshotId", "RuleId");
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
- b.HasIndex("RuleId", "SnapshotId");
+ b.Property("RemovedBySnapshotId");
+
+ b.HasKey("AddedBySnapshotId", "RuleId");
+
+ b.HasIndex("RemovedBySnapshotId");
+
+ b.HasIndex("RuleId");
b.ToTable("snapshots_rules");
});
@@ -182,7 +190,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("SyntaxId", "SoftwareId");
- b.HasIndex("SoftwareId", "SyntaxId");
+ b.HasIndex("SoftwareId");
b.ToTable("software_syntaxes");
});
@@ -470,15 +478,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b =>
{
+ b.HasOne("FilterLists.Data.Entities.Snapshot", "AddedBySnapshot")
+ .WithMany("AddedSnapshotRules")
+ .HasForeignKey("AddedBySnapshotId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.Snapshot", "RemovedBySnapshot")
+ .WithMany("RemovedSnapshotRules")
+ .HasForeignKey("RemovedBySnapshotId")
+ .OnDelete(DeleteBehavior.Cascade);
+
b.HasOne("FilterLists.Data.Entities.Rule", "Rule")
.WithMany("SnapshotRules")
.HasForeignKey("RuleId")
.OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.Snapshot", "Snapshot")
- .WithMany("SnapshotRules")
- .HasForeignKey("SnapshotId")
- .OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b =>
diff --git a/src/FilterLists.Api/Migrations/20180208153839_InitialCreate.cs b/src/FilterLists.Api/Migrations/20180210130730_InitialCreate.cs
similarity index 93%
rename from src/FilterLists.Api/Migrations/20180208153839_InitialCreate.cs
rename to src/FilterLists.Api/Migrations/20180210130730_InitialCreate.cs
index c18bb1289..717f097d6 100644
--- a/src/FilterLists.Api/Migrations/20180208153839_InitialCreate.cs
+++ b/src/FilterLists.Api/Migrations/20180210130730_InitialCreate.cs
@@ -301,7 +301,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
FilterListId = table.Column(nullable: false),
- HttpStatusCode = table.Column("SMALLINT UNSIGNED", nullable: true)
+ HttpStatusCode = table.Column("VARCHAR(3)", nullable: true, defaultValueSql: "NULL")
},
constraints: table =>
{
@@ -318,27 +318,35 @@ protected override void Up(MigrationBuilder migrationBuilder)
"snapshots_rules",
table => new
{
- SnapshotId = table.Column(nullable: false),
+ AddedBySnapshotId = table.Column(nullable: false),
RuleId = table.Column(nullable: false),
CreatedDateUtc = table.Column("TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy",
- MySqlValueGenerationStrategy.IdentityColumn)
+ MySqlValueGenerationStrategy.IdentityColumn),
+ ModifiedDateUtc = table.Column("TIMESTAMP", nullable: false),
+ RemovedBySnapshotId = table.Column(nullable: true)
},
constraints: table =>
{
- table.PrimaryKey("PK_snapshots_rules", x => new {x.SnapshotId, x.RuleId});
+ table.PrimaryKey("PK_snapshots_rules", x => new {x.AddedBySnapshotId, x.RuleId});
+ table.ForeignKey(
+ "FK_snapshots_rules_snapshots_AddedBySnapshotId",
+ x => x.AddedBySnapshotId,
+ "snapshots",
+ "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ "FK_snapshots_rules_snapshots_RemovedBySnapshotId",
+ x => x.RemovedBySnapshotId,
+ "snapshots",
+ "Id",
+ onDelete: ReferentialAction.Cascade);
table.ForeignKey(
"FK_snapshots_rules_rules_RuleId",
x => x.RuleId,
"rules",
"Id",
onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- "FK_snapshots_rules_snapshots_SnapshotId",
- x => x.SnapshotId,
- "snapshots",
- "Id",
- onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
@@ -352,24 +360,24 @@ protected override void Up(MigrationBuilder migrationBuilder)
"SyntaxId");
migrationBuilder.CreateIndex(
- "IX_filterlists_languages_LanguageId_FilterListId",
+ "IX_filterlists_languages_LanguageId",
"filterlists_languages",
- new[] {"LanguageId", "FilterListId"});
+ "LanguageId");
migrationBuilder.CreateIndex(
- "IX_filterlists_maintainers_MaintainerId_FilterListId",
+ "IX_filterlists_maintainers_MaintainerId",
"filterlists_maintainers",
- new[] {"MaintainerId", "FilterListId"});
+ "MaintainerId");
migrationBuilder.CreateIndex(
- "IX_forks_UpstreamFilterListId_ForkFilterListId",
+ "IX_forks_UpstreamFilterListId",
"forks",
- new[] {"UpstreamFilterListId", "ForkFilterListId"});
+ "UpstreamFilterListId");
migrationBuilder.CreateIndex(
- "IX_merges_UpstreamFilterListId_MergeFilterListId",
+ "IX_merges_UpstreamFilterListId",
"merges",
- new[] {"UpstreamFilterListId", "MergeFilterListId"});
+ "UpstreamFilterListId");
migrationBuilder.CreateIndex(
"IX_snapshots_FilterListId",
@@ -377,14 +385,19 @@ protected override void Up(MigrationBuilder migrationBuilder)
"FilterListId");
migrationBuilder.CreateIndex(
- "IX_snapshots_rules_RuleId_SnapshotId",
+ "IX_snapshots_rules_RemovedBySnapshotId",
"snapshots_rules",
- new[] {"RuleId", "SnapshotId"});
+ "RemovedBySnapshotId");
migrationBuilder.CreateIndex(
- "IX_software_syntaxes_SoftwareId_SyntaxId",
+ "IX_snapshots_rules_RuleId",
+ "snapshots_rules",
+ "RuleId");
+
+ migrationBuilder.CreateIndex(
+ "IX_software_syntaxes_SoftwareId",
"software_syntaxes",
- new[] {"SoftwareId", "SyntaxId"});
+ "SoftwareId");
}
protected override void Down(MigrationBuilder migrationBuilder)
@@ -414,10 +427,10 @@ protected override void Down(MigrationBuilder migrationBuilder)
"maintainers");
migrationBuilder.DropTable(
- "rules");
+ "snapshots");
migrationBuilder.DropTable(
- "snapshots");
+ "rules");
migrationBuilder.DropTable(
"software");
diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
index b43d5df3c..8fc1bd536 100644
--- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
+++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
@@ -95,7 +95,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "LanguageId");
- b.HasIndex("LanguageId", "FilterListId");
+ b.HasIndex("LanguageId");
b.ToTable("filterlists_languages");
});
@@ -112,7 +112,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "MaintainerId");
- b.HasIndex("MaintainerId", "FilterListId");
+ b.HasIndex("MaintainerId");
b.ToTable("filterlists_maintainers");
});
@@ -129,7 +129,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("ForkFilterListId", "UpstreamFilterListId");
- b.HasIndex("UpstreamFilterListId", "ForkFilterListId");
+ b.HasIndex("UpstreamFilterListId");
b.ToTable("forks");
});
@@ -146,14 +146,14 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("MergeFilterListId", "UpstreamFilterListId");
- b.HasIndex("UpstreamFilterListId", "MergeFilterListId");
+ b.HasIndex("UpstreamFilterListId");
b.ToTable("merges");
});
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b =>
{
- b.Property("SnapshotId");
+ b.Property("AddedBySnapshotId");
b.Property("RuleId");
@@ -161,9 +161,17 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
- b.HasKey("SnapshotId", "RuleId");
+ b.Property("ModifiedDateUtc")
+ .ValueGeneratedOnAddOrUpdate()
+ .HasColumnType("TIMESTAMP");
- b.HasIndex("RuleId", "SnapshotId");
+ b.Property("RemovedBySnapshotId");
+
+ b.HasKey("AddedBySnapshotId", "RuleId");
+
+ b.HasIndex("RemovedBySnapshotId");
+
+ b.HasIndex("RuleId");
b.ToTable("snapshots_rules");
});
@@ -180,7 +188,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("SyntaxId", "SoftwareId");
- b.HasIndex("SoftwareId", "SyntaxId");
+ b.HasIndex("SoftwareId");
b.ToTable("software_syntaxes");
});
@@ -468,15 +476,20 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SnapshotRule", b =>
{
+ b.HasOne("FilterLists.Data.Entities.Snapshot", "AddedBySnapshot")
+ .WithMany("AddedSnapshotRules")
+ .HasForeignKey("AddedBySnapshotId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("FilterLists.Data.Entities.Snapshot", "RemovedBySnapshot")
+ .WithMany("RemovedSnapshotRules")
+ .HasForeignKey("RemovedBySnapshotId")
+ .OnDelete(DeleteBehavior.Cascade);
+
b.HasOne("FilterLists.Data.Entities.Rule", "Rule")
.WithMany("SnapshotRules")
.HasForeignKey("RuleId")
.OnDelete(DeleteBehavior.Cascade);
-
- b.HasOne("FilterLists.Data.Entities.Snapshot", "Snapshot")
- .WithMany("SnapshotRules")
- .HasForeignKey("SnapshotId")
- .OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b =>
diff --git a/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs b/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs
index f398b8467..b310d98d3 100644
--- a/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs
+++ b/src/FilterLists.Data/Entities/Junctions/SnapshotRule.cs
@@ -1,9 +1,14 @@
-namespace FilterLists.Data.Entities.Junctions
+using System;
+
+namespace FilterLists.Data.Entities.Junctions
{
public class SnapshotRule : BaseJunction
{
- public int SnapshotId { get; set; }
- public Snapshot Snapshot { get; set; }
+ public DateTime ModifiedDateUtc { get; set; }
+ public int AddedBySnapshotId { get; set; }
+ public Snapshot AddedBySnapshot { get; set; }
+ public int? RemovedBySnapshotId { get; set; }
+ public Snapshot RemovedBySnapshot { get; set; }
public int RuleId { get; set; }
public Rule Rule { get; set; }
}
diff --git a/src/FilterLists.Data/Entities/Snapshot.cs b/src/FilterLists.Data/Entities/Snapshot.cs
index 513c17ab9..e1efba0f3 100644
--- a/src/FilterLists.Data/Entities/Snapshot.cs
+++ b/src/FilterLists.Data/Entities/Snapshot.cs
@@ -8,6 +8,7 @@ public class Snapshot : BaseEntity
public int FilterListId { get; set; }
public FilterList FilterList { get; set; }
public string HttpStatusCode { get; set; }
- public ICollection SnapshotRules { get; set; }
+ public ICollection AddedSnapshotRules { get; set; }
+ public ICollection RemovedSnapshotRules { get; set; }
}
}
\ No newline at end of file
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs
index 0cd8fbf11..75d3c65ce 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs
@@ -11,7 +11,6 @@ public override void Configure(EntityTypeBuilder entityTypeB
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("filterlists_languages");
entityTypeBuilder.HasKey(x => new {x.FilterListId, x.LanguageId});
- entityTypeBuilder.HasIndex(x => new {x.LanguageId, x.FilterListId});
entityTypeBuilder.HasOne(x => x.FilterList)
.WithMany(x => x.FilterListLanguages)
.HasForeignKey(x => x.FilterListId);
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs
index 124c34ec1..eb36c24bc 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs
@@ -11,7 +11,6 @@ public override void Configure(EntityTypeBuilder entityTyp
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("filterlists_maintainers");
entityTypeBuilder.HasKey(x => new {x.FilterListId, x.MaintainerId});
- entityTypeBuilder.HasIndex(x => new {x.MaintainerId, x.FilterListId});
entityTypeBuilder.HasOne(x => x.FilterList)
.WithMany(x => x.FilterListMaintainers)
.HasForeignKey(x => x.FilterListId);
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs
index 78c3a7446..c1b6e9abd 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs
@@ -11,7 +11,6 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder)
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("forks");
entityTypeBuilder.HasKey(x => new {x.ForkFilterListId, x.UpstreamFilterListId});
- entityTypeBuilder.HasIndex(x => new {x.UpstreamFilterListId, x.ForkFilterListId});
entityTypeBuilder.HasOne(x => x.ForkFilterList)
.WithMany(x => x.ForkFilterLists)
.HasForeignKey(x => x.ForkFilterListId);
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs
index 7bc286965..c527526ce 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs
@@ -11,7 +11,6 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder)
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("merges");
entityTypeBuilder.HasKey(x => new {x.MergeFilterListId, x.UpstreamFilterListId});
- entityTypeBuilder.HasIndex(x => new {x.UpstreamFilterListId, x.MergeFilterListId});
entityTypeBuilder.HasOne(x => x.MergeFilterList)
.WithMany(x => x.MergeFilterLists)
.HasForeignKey(x => x.MergeFilterListId);
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs
index 547fc6534..2f16a59b3 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs
@@ -10,11 +10,17 @@ public override void Configure(EntityTypeBuilder entityTypeBuilder
{
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("snapshots_rules");
- entityTypeBuilder.HasKey(x => new {x.SnapshotId, x.RuleId});
- entityTypeBuilder.HasIndex(x => new {x.RuleId, x.SnapshotId});
- entityTypeBuilder.HasOne(x => x.Snapshot)
- .WithMany(x => x.SnapshotRules)
- .HasForeignKey(x => x.SnapshotId);
+ entityTypeBuilder.HasKey(x => new {x.AddedBySnapshotId, x.RuleId});
+ entityTypeBuilder.Property(x => x.ModifiedDateUtc)
+ .HasColumnType("TIMESTAMP")
+ .ValueGeneratedOnAddOrUpdate();
+ entityTypeBuilder.HasOne(x => x.AddedBySnapshot)
+ .WithMany(x => x.AddedSnapshotRules)
+ .HasForeignKey(x => x.AddedBySnapshotId);
+ entityTypeBuilder.HasOne(x => x.RemovedBySnapshot)
+ .WithMany(x => x.RemovedSnapshotRules)
+ .HasForeignKey(x => x.RemovedBySnapshotId)
+ .OnDelete(DeleteBehavior.Cascade);
entityTypeBuilder.HasOne(x => x.Rule)
.WithMany(x => x.SnapshotRules)
.HasForeignKey(x => x.RuleId);
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs
index 6093346ef..1d54dac9b 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs
@@ -11,7 +11,6 @@ public override void Configure(EntityTypeBuilder entityTypeBuild
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("software_syntaxes");
entityTypeBuilder.HasKey(x => new {x.SyntaxId, x.SoftwareId});
- entityTypeBuilder.HasIndex(x => new {x.SoftwareId, x.SyntaxId});
entityTypeBuilder.HasOne(x => x.Software)
.WithMany(x => x.SoftwareSyntaxes)
.HasForeignKey(x => x.SoftwareId);
diff --git a/src/FilterLists.Services/SnapshotService/SnapshotBatchDe.cs b/src/FilterLists.Services/SnapshotService/SnapshotBatchDe.cs
index 8a3d84813..80cb4dcbb 100644
--- a/src/FilterLists.Services/SnapshotService/SnapshotBatchDe.cs
+++ b/src/FilterLists.Services/SnapshotService/SnapshotBatchDe.cs
@@ -23,6 +23,7 @@ public SnapshotBatchDe(FilterListsDbContext dbContext, Snapshot snapshot, IEnume
this.rawRules = rawRules;
}
+ //TODO: support de-duplicated SnapshotRule
public async Task SaveSnapshotBatchAsync()
{
AddNewRules();
@@ -41,11 +42,11 @@ private void AddNewRules()
private void AddSnapshotRules()
{
- if (snapshot.SnapshotRules == null)
- snapshot.SnapshotRules = new List();
- snapshot.SnapshotRules.AddRange(preExistingSnapshotRules
+ if (snapshot.AddedSnapshotRules == null)
+ snapshot.AddedSnapshotRules = new List();
+ snapshot.AddedSnapshotRules.AddRange(preExistingSnapshotRules
.Concat(newSnapshotRules)
- .Select(rule => new SnapshotRule {Rule = rule, Snapshot = snapshot})
+ .Select(rule => new SnapshotRule {Rule = rule, AddedBySnapshot = snapshot})
.ToList());
}
}