diff --git a/src/FilterLists.Api/FilterLists.Api.csproj b/src/FilterLists.Api/FilterLists.Api.csproj
index b00a9bd09..329f4cbdc 100644
--- a/src/FilterLists.Api/FilterLists.Api.csproj
+++ b/src/FilterLists.Api/FilterLists.Api.csproj
@@ -18,7 +18,6 @@
-
diff --git a/src/FilterLists.Api/Migrations/20180207235556_InitialReCreate.Designer.cs b/src/FilterLists.Api/Migrations/20180208145019_InitialCreate.Designer.cs
similarity index 97%
rename from src/FilterLists.Api/Migrations/20180207235556_InitialReCreate.Designer.cs
rename to src/FilterLists.Api/Migrations/20180208145019_InitialCreate.Designer.cs
index 145b48ff7..29f03bd7a 100644
--- a/src/FilterLists.Api/Migrations/20180207235556_InitialReCreate.Designer.cs
+++ b/src/FilterLists.Api/Migrations/20180208145019_InitialCreate.Designer.cs
@@ -10,8 +10,8 @@
namespace FilterLists.Api.Migrations
{
[DbContext(typeof(FilterListsDbContext))]
- [Migration("20180207235556_InitialReCreate")]
- partial class InitialReCreate
+ [Migration("20180208145019_InitialCreate")]
+ partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -97,6 +97,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "LanguageId");
+ b.HasIndex("LanguageId", "FilterListId");
+
b.ToTable("filterlists_languages");
});
@@ -112,6 +114,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "MaintainerId");
+ b.HasIndex("MaintainerId", "FilterListId");
+
b.ToTable("filterlists_maintainers");
});
@@ -127,6 +131,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("ForkFilterListId", "UpstreamFilterListId");
+ b.HasIndex("UpstreamFilterListId", "ForkFilterListId");
+
b.ToTable("forks");
});
@@ -142,6 +148,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("MergeFilterListId", "UpstreamFilterListId");
+ b.HasIndex("UpstreamFilterListId", "MergeFilterListId");
+
b.ToTable("merges");
});
@@ -157,20 +165,24 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasKey("SnapshotId", "RuleId");
+ b.HasIndex("RuleId", "SnapshotId");
+
b.ToTable("snapshots_rules");
});
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b =>
{
- b.Property("SoftwareId");
-
b.Property("SyntaxId");
+ b.Property("SoftwareId");
+
b.Property("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
- b.HasKey("SoftwareId", "SyntaxId");
+ b.HasKey("SyntaxId", "SoftwareId");
+
+ b.HasIndex("SoftwareId", "SyntaxId");
b.ToTable("software_syntaxes");
});
diff --git a/src/FilterLists.Api/Migrations/20180207235556_InitialReCreate.cs b/src/FilterLists.Api/Migrations/20180208145019_InitialCreate.cs
similarity index 93%
rename from src/FilterLists.Api/Migrations/20180207235556_InitialReCreate.cs
rename to src/FilterLists.Api/Migrations/20180208145019_InitialCreate.cs
index fa3b2515c..a1c31af80 100644
--- a/src/FilterLists.Api/Migrations/20180207235556_InitialReCreate.cs
+++ b/src/FilterLists.Api/Migrations/20180208145019_InitialCreate.cs
@@ -5,7 +5,7 @@
namespace FilterLists.Api.Migrations
{
- public partial class InitialReCreate : Migration
+ public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@@ -164,14 +164,14 @@ protected override void Up(MigrationBuilder migrationBuilder)
name: "software_syntaxes",
columns: table => new
{
- SoftwareId = table.Column(nullable: false),
SyntaxId = table.Column(nullable: false),
+ SoftwareId = table.Column(nullable: false),
CreatedDateUtc = table.Column(type: "TIMESTAMP", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
},
constraints: table =>
{
- table.PrimaryKey("PK_software_syntaxes", x => new { x.SoftwareId, x.SyntaxId });
+ table.PrimaryKey("PK_software_syntaxes", x => new { x.SyntaxId, x.SoftwareId });
table.ForeignKey(
name: "FK_software_syntaxes_software_SoftwareId",
column: x => x.SoftwareId,
@@ -348,10 +348,40 @@ protected override void Up(MigrationBuilder migrationBuilder)
table: "filterlists",
column: "SyntaxId");
+ migrationBuilder.CreateIndex(
+ name: "IX_filterlists_languages_LanguageId_FilterListId",
+ table: "filterlists_languages",
+ columns: new[] { "LanguageId", "FilterListId" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_filterlists_maintainers_MaintainerId_FilterListId",
+ table: "filterlists_maintainers",
+ columns: new[] { "MaintainerId", "FilterListId" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_forks_UpstreamFilterListId_ForkFilterListId",
+ table: "forks",
+ columns: new[] { "UpstreamFilterListId", "ForkFilterListId" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_merges_UpstreamFilterListId_MergeFilterListId",
+ table: "merges",
+ columns: new[] { "UpstreamFilterListId", "MergeFilterListId" });
+
migrationBuilder.CreateIndex(
name: "IX_snapshots_FilterListId",
table: "snapshots",
column: "FilterListId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_snapshots_rules_RuleId_SnapshotId",
+ table: "snapshots_rules",
+ columns: new[] { "RuleId", "SnapshotId" });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_software_syntaxes_SoftwareId_SyntaxId",
+ table: "software_syntaxes",
+ columns: new[] { "SoftwareId", "SyntaxId" });
}
protected override void Down(MigrationBuilder migrationBuilder)
diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
index c92eaf9da..f09173cc2 100644
--- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
+++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs
@@ -96,6 +96,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "LanguageId");
+ b.HasIndex("LanguageId", "FilterListId");
+
b.ToTable("filterlists_languages");
});
@@ -111,6 +113,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("FilterListId", "MaintainerId");
+ b.HasIndex("MaintainerId", "FilterListId");
+
b.ToTable("filterlists_maintainers");
});
@@ -126,6 +130,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("ForkFilterListId", "UpstreamFilterListId");
+ b.HasIndex("UpstreamFilterListId", "ForkFilterListId");
+
b.ToTable("forks");
});
@@ -141,6 +147,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("MergeFilterListId", "UpstreamFilterListId");
+ b.HasIndex("UpstreamFilterListId", "MergeFilterListId");
+
b.ToTable("merges");
});
@@ -156,20 +164,24 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("SnapshotId", "RuleId");
+ b.HasIndex("RuleId", "SnapshotId");
+
b.ToTable("snapshots_rules");
});
modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b =>
{
- b.Property("SoftwareId");
-
b.Property("SyntaxId");
+ b.Property("SoftwareId");
+
b.Property("CreatedDateUtc")
.ValueGeneratedOnAdd()
.HasColumnType("TIMESTAMP");
- b.HasKey("SoftwareId", "SyntaxId");
+ b.HasKey("SyntaxId", "SoftwareId");
+
+ b.HasIndex("SoftwareId", "SyntaxId");
b.ToTable("software_syntaxes");
});
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs
index 75d3c65ce..0cd8fbf11 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs
@@ -11,6 +11,7 @@ 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 eb36c24bc..124c34ec1 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs
@@ -11,6 +11,7 @@ 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 c1b6e9abd..78c3a7446 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs
@@ -11,6 +11,7 @@ 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 c527526ce..7bc286965 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/MergeTypeConfiguration.cs
@@ -11,6 +11,7 @@ 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 52df04c6a..547fc6534 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs
@@ -11,6 +11,7 @@ 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);
diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs
index 8f40f9928..6093346ef 100644
--- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs
+++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs
@@ -10,7 +10,8 @@ public override void Configure(EntityTypeBuilder entityTypeBuild
{
base.Configure(entityTypeBuilder);
entityTypeBuilder.ToTable("software_syntaxes");
- entityTypeBuilder.HasKey(x => new {x.SoftwareId, x.SyntaxId});
+ 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.Data/FilterListsDbContext.cs b/src/FilterLists.Data/FilterListsDbContext.cs
index 449a80635..58db3ca61 100644
--- a/src/FilterLists.Data/FilterListsDbContext.cs
+++ b/src/FilterLists.Data/FilterListsDbContext.cs
@@ -1,10 +1,8 @@
-using System.Linq;
-using FilterLists.Data.Entities;
+using FilterLists.Data.Entities;
using FilterLists.Data.Entities.Junctions;
using FilterLists.Data.EntityTypeConfigurations;
using FilterLists.Data.EntityTypeConfigurations.Junctions;
using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Internal;
namespace FilterLists.Data
{
@@ -19,19 +17,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
base.OnModelCreating(modelBuilder);
ApplyConfigurationsEntities(modelBuilder);
ApplyConfigurationsJunctions(modelBuilder);
- SelectivelyOmitConventions(modelBuilder);
- }
-
- //TODO: update when official API supported
- //https://github.com/aspnet/EntityFrameworkCore/issues/10855#issuecomment-363219253
- //https://github.com/aspnet/EntityFrameworkCore/issues/7605
- private static void SelectivelyOmitConventions(ModelBuilder modelBuilder)
- {
- ((Model)modelBuilder.Model).ConventionDispatcher.StartBatch();
- foreach (var entityType in modelBuilder.Model.GetEntityTypes())
- foreach (var index in entityType.GetIndexes().ToList())
- if (index.DeclaringEntityType.Name.Contains("Junctions"))
- entityType.RemoveIndex(index.Properties);
}
#region Entities