From fa3b61cade6454a87bb7a0c7f9c7ef47ef3cc418 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Tue, 6 Feb 2018 10:19:11 -0600 Subject: [PATCH] add junction composite indices --- ...03_AddJunctionCompositeIndices.Designer.cs | 523 ++++++++++++++++++ ...80206161803_AddJunctionCompositeIndices.cs | 75 +++ .../FilterListsDbContextModelSnapshot.cs | 18 + .../FilterListLanguageTypeConfiguration.cs | 7 + .../FilterListMaintainerTypeConfiguration.cs | 7 + .../Junctions/ForkTypeConfiguration.cs | 1 + .../Junctions/MergeTypeConfiguration.cs | 1 + .../SnapshotRuleTypeConfiguration.cs | 7 + .../SoftwareSyntaxTypeConfiguration.cs | 7 + 9 files changed, 646 insertions(+) create mode 100644 src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.Designer.cs create mode 100644 src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.cs diff --git a/src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.Designer.cs b/src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.Designer.cs new file mode 100644 index 000000000..3eb120b1e --- /dev/null +++ b/src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.Designer.cs @@ -0,0 +1,523 @@ +// +using FilterLists.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; +using System; + +namespace FilterLists.Api.Migrations +{ + [DbContext(typeof(FilterListsDbContext))] + [Migration("20180206161803_AddJunctionCompositeIndices")] + partial class AddJunctionCompositeIndices + { + 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"); + + b.HasIndex("FilterListId", "LanguageId") + .IsUnique(); + + 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"); + + b.HasIndex("FilterListId", "MaintainerId") + .IsUnique(); + + 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"); + + b.HasIndex("ForkFilterListId", "UpstreamFilterListId") + .IsUnique(); + + 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"); + + b.HasIndex("MergeFilterListId", "UpstreamFilterListId") + .IsUnique(); + + 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"); + + b.HasIndex("SnapshotId", "RuleId") + .IsUnique(); + + b.ToTable("snapshots_rules"); + }); + + modelBuilder.Entity("FilterLists.Data.Entities.Junctions.SoftwareSyntax", b => + { + b.Property("SoftwareId"); + + b.Property("SyntaxId"); + + b.Property("CreatedDateUtc") + .ValueGeneratedOnAdd() + .HasColumnType("TIMESTAMP"); + + b.HasKey("SoftwareId", "SyntaxId"); + + b.HasIndex("SyntaxId"); + + b.HasIndex("SoftwareId", "SyntaxId") + .IsUnique(); + + 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("SMALLINT 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("BIGINT 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("SMALLINT 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("SMALLINT 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 + } + } +} diff --git a/src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.cs b/src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.cs new file mode 100644 index 000000000..165df754b --- /dev/null +++ b/src/FilterLists.Api/Migrations/20180206161803_AddJunctionCompositeIndices.cs @@ -0,0 +1,75 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; + +namespace FilterLists.Api.Migrations +{ + public partial class AddJunctionCompositeIndices : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_software_syntaxes_SoftwareId_SyntaxId", + table: "software_syntaxes", + columns: new[] { "SoftwareId", "SyntaxId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_snapshots_rules_SnapshotId_RuleId", + table: "snapshots_rules", + columns: new[] { "SnapshotId", "RuleId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_merges_MergeFilterListId_UpstreamFilterListId", + table: "merges", + columns: new[] { "MergeFilterListId", "UpstreamFilterListId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_forks_ForkFilterListId_UpstreamFilterListId", + table: "forks", + columns: new[] { "ForkFilterListId", "UpstreamFilterListId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_maintainers_FilterListId_MaintainerId", + table: "filterlists_maintainers", + columns: new[] { "FilterListId", "MaintainerId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_filterlists_languages_FilterListId_LanguageId", + table: "filterlists_languages", + columns: new[] { "FilterListId", "LanguageId" }, + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_software_syntaxes_SoftwareId_SyntaxId", + table: "software_syntaxes"); + + migrationBuilder.DropIndex( + name: "IX_snapshots_rules_SnapshotId_RuleId", + table: "snapshots_rules"); + + migrationBuilder.DropIndex( + name: "IX_merges_MergeFilterListId_UpstreamFilterListId", + table: "merges"); + + migrationBuilder.DropIndex( + name: "IX_forks_ForkFilterListId_UpstreamFilterListId", + table: "forks"); + + migrationBuilder.DropIndex( + name: "IX_filterlists_maintainers_FilterListId_MaintainerId", + table: "filterlists_maintainers"); + + migrationBuilder.DropIndex( + name: "IX_filterlists_languages_FilterListId_LanguageId", + table: "filterlists_languages"); + } + } +} diff --git a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs index ff6153e25..0dd5a0113 100644 --- a/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs +++ b/src/FilterLists.Api/Migrations/FilterListsDbContextModelSnapshot.cs @@ -98,6 +98,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("LanguageId"); + b.HasIndex("FilterListId", "LanguageId") + .IsUnique(); + b.ToTable("filterlists_languages"); }); @@ -115,6 +118,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("MaintainerId"); + b.HasIndex("FilterListId", "MaintainerId") + .IsUnique(); + b.ToTable("filterlists_maintainers"); }); @@ -132,6 +138,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("UpstreamFilterListId"); + b.HasIndex("ForkFilterListId", "UpstreamFilterListId") + .IsUnique(); + b.ToTable("forks"); }); @@ -149,6 +158,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("UpstreamFilterListId"); + b.HasIndex("MergeFilterListId", "UpstreamFilterListId") + .IsUnique(); + b.ToTable("merges"); }); @@ -166,6 +178,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("RuleId"); + b.HasIndex("SnapshotId", "RuleId") + .IsUnique(); + b.ToTable("snapshots_rules"); }); @@ -183,6 +198,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SyntaxId"); + b.HasIndex("SoftwareId", "SyntaxId") + .IsUnique(); + b.ToTable("software_syntaxes"); }); diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs index 7d9b5b8d2..1bd33ee7a 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListLanguageTypeConfiguration.cs @@ -11,6 +11,13 @@ 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.FilterListId, x.LanguageId}).IsUnique(); + entityTypeBuilder.HasOne(x => x.FilterList) + .WithMany(x => x.FilterListLanguages) + .HasForeignKey(x => x.FilterListId); + entityTypeBuilder.HasOne(x => x.Language) + .WithMany(x => x.FilterListLanguages) + .HasForeignKey(x => x.LanguageId); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs index 0e5df61bb..34d542be6 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/FilterListMaintainerTypeConfiguration.cs @@ -11,6 +11,13 @@ 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.FilterListId, x.MaintainerId}).IsUnique(); + entityTypeBuilder.HasOne(x => x.FilterList) + .WithMany(x => x.FilterListMaintainers) + .HasForeignKey(x => x.FilterListId); + entityTypeBuilder.HasOne(x => x.Maintainer) + .WithMany(x => x.FilterListMaintainers) + .HasForeignKey(x => x.MaintainerId); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/ForkTypeConfiguration.cs index c1b6e9abd..ee7d1567d 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.ForkFilterListId, x.UpstreamFilterListId}).IsUnique(); 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..6ed9159ab 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.MergeFilterListId, x.UpstreamFilterListId}).IsUnique(); 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 f21c612fb..38d4f821c 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SnapshotRuleTypeConfiguration.cs @@ -11,6 +11,13 @@ 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.SnapshotId, x.RuleId}).IsUnique(); + entityTypeBuilder.HasOne(x => x.Snapshot) + .WithMany(x => x.SnapshotRules) + .HasForeignKey(x => x.SnapshotId); + entityTypeBuilder.HasOne(x => x.Rule) + .WithMany(x => x.SnapshotRules) + .HasForeignKey(x => x.RuleId); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs index b7b14638f..e5767193c 100644 --- a/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs +++ b/src/FilterLists.Data/EntityTypeConfigurations/Junctions/SoftwareSyntaxTypeConfiguration.cs @@ -11,6 +11,13 @@ public override void Configure(EntityTypeBuilder entityTypeBuild base.Configure(entityTypeBuilder); entityTypeBuilder.ToTable("software_syntaxes"); entityTypeBuilder.HasKey(x => new {x.SoftwareId, x.SyntaxId}); + entityTypeBuilder.HasIndex(x => new {x.SoftwareId, x.SyntaxId}).IsUnique(); + entityTypeBuilder.HasOne(x => x.Software) + .WithMany(x => x.SoftwareSyntaxes) + .HasForeignKey(x => x.SoftwareId); + entityTypeBuilder.HasOne(x => x.Syntax) + .WithMany(x => x.SoftwareSyntaxes) + .HasForeignKey(x => x.SyntaxId); } } } \ No newline at end of file