mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(directory): ✨ convert ViewUrls to owned entities
This commit is contained in:
parent
1a7dac7af1
commit
9043a161e4
6 changed files with 130 additions and 160 deletions
|
|
@ -10,7 +10,7 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Migrations.Migrations
|
||||
{
|
||||
[DbContext(typeof(QueryDbContext))]
|
||||
[Migration("20200825210326_Initial")]
|
||||
[Migration("20200825215253_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
|
|
@ -238,52 +238,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.ToTable("Merges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Position")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FilterListId", "Position")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("SegmentViewUrls");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrlMirror", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("SegmentViewUrlId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SegmentViewUrlId");
|
||||
|
||||
b.ToTable("SegmentViewUrlMirrors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Software", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
|
@ -388,6 +342,58 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.License", "License")
|
||||
.WithMany("FilterLists")
|
||||
.HasForeignKey("LicenseId");
|
||||
|
||||
b.OwnsMany("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", "SegmentViewUrls", b1 =>
|
||||
{
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b1.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("Position")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("FilterListId", "Position")
|
||||
.IsUnique();
|
||||
|
||||
b1.ToTable("SegmentViewUrls");
|
||||
|
||||
b1.WithOwner("FilterList")
|
||||
.HasForeignKey("FilterListId");
|
||||
|
||||
b1.OwnsMany("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrlMirror", "SegmentViewUrlMirrors", b2 =>
|
||||
{
|
||||
b2.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b2.Property<int>("SegmentViewUrlId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b2.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b2.HasKey("Id");
|
||||
|
||||
b2.HasIndex("SegmentViewUrlId");
|
||||
|
||||
b2.ToTable("SegmentViewUrlMirrors");
|
||||
|
||||
b2.WithOwner("SegmentViewUrl")
|
||||
.HasForeignKey("SegmentViewUrlId");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListLanguage", b =>
|
||||
|
|
@ -480,24 +486,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "FilterList")
|
||||
.WithMany("SegmentViewUrls")
|
||||
.HasForeignKey("FilterListId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrlMirror", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", "SegmentViewUrl")
|
||||
.WithMany("SegmentViewUrlMirrors")
|
||||
.HasForeignKey("SegmentViewUrlId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SoftwareSyntax", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Software", "Software")
|
||||
|
|
@ -236,52 +236,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.ToTable("Merges");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Position")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FilterListId", "Position")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("SegmentViewUrls");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrlMirror", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("SegmentViewUrlId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SegmentViewUrlId");
|
||||
|
||||
b.ToTable("SegmentViewUrlMirrors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Software", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
|
@ -386,6 +340,58 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.License", "License")
|
||||
.WithMany("FilterLists")
|
||||
.HasForeignKey("LicenseId");
|
||||
|
||||
b.OwnsMany("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", "SegmentViewUrls", b1 =>
|
||||
{
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b1.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("Position")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("FilterListId", "Position")
|
||||
.IsUnique();
|
||||
|
||||
b1.ToTable("SegmentViewUrls");
|
||||
|
||||
b1.WithOwner("FilterList")
|
||||
.HasForeignKey("FilterListId");
|
||||
|
||||
b1.OwnsMany("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrlMirror", "SegmentViewUrlMirrors", b2 =>
|
||||
{
|
||||
b2.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b2.Property<int>("SegmentViewUrlId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b2.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b2.HasKey("Id");
|
||||
|
||||
b2.HasIndex("SegmentViewUrlId");
|
||||
|
||||
b2.ToTable("SegmentViewUrlMirrors");
|
||||
|
||||
b2.WithOwner("SegmentViewUrl")
|
||||
.HasForeignKey("SegmentViewUrlId");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListLanguage", b =>
|
||||
|
|
@ -478,24 +484,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "FilterList")
|
||||
.WithMany("SegmentViewUrls")
|
||||
.HasForeignKey("FilterListId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrlMirror", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SegmentViewUrl", "SegmentViewUrl")
|
||||
.WithMany("SegmentViewUrlMirrors")
|
||||
.HasForeignKey("SegmentViewUrlId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.SoftwareSyntax", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Software", "Software")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
|
|
@ -33,4 +35,27 @@ public class FilterList
|
|||
public IReadOnlyCollection<Dependent> DependencyFilterLists { get; private set; } = new HashSet<Dependent>();
|
||||
public IReadOnlyCollection<Dependent> DependentFilterLists { get; private set; } = new HashSet<Dependent>();
|
||||
}
|
||||
|
||||
internal class FilterListTypeConfiguration : IEntityTypeConfiguration<FilterList>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
builder.OwnsMany(fl => fl.SegmentViewUrls,
|
||||
o =>
|
||||
{
|
||||
o.ToTable(nameof(SegmentViewUrl) + "s");
|
||||
o.HasKey("Id");
|
||||
o.HasIndex(nameof(FilterList) + "Id", nameof(SegmentViewUrl.Position)).IsUnique();
|
||||
o.OwnsMany(p => p.SegmentViewUrlMirrors,
|
||||
m =>
|
||||
{
|
||||
m.ToTable(nameof(SegmentViewUrlMirror) + "s");
|
||||
m.Property<int>("Id");
|
||||
m.HasKey("Id");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
|
||||
public class SegmentViewUrl
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int FilterListId { get; set; }
|
||||
public FilterList FilterList { get; private set; } = null!;
|
||||
public int Position { get; private set; }
|
||||
public Uri Url { get; private set; } = null!;
|
||||
public IReadOnlyCollection<SegmentViewUrlMirror> SegmentViewUrlMirrors { get; private set; } = new HashSet<SegmentViewUrlMirror>();
|
||||
}
|
||||
|
||||
internal class ViewUrlPartialTypeConfiguration : IEntityTypeConfiguration<SegmentViewUrl>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<SegmentViewUrl> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
builder.ToTable(nameof(SegmentViewUrl) + "s");
|
||||
|
||||
builder.HasIndex(s => new {s.FilterListId, s.Position})
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +1,12 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
|
||||
public class SegmentViewUrlMirror
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int SegmentViewUrlId { get; private set; }
|
||||
public SegmentViewUrl SegmentViewUrl { get; private set; } = null!;
|
||||
public Uri Url { get; private set; } = null!;
|
||||
}
|
||||
|
||||
internal class ViewUrlMirrorTypeConfiguration : IEntityTypeConfiguration<SegmentViewUrlMirror>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<SegmentViewUrlMirror> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
|
||||
builder.ToTable(nameof(SegmentViewUrlMirror) + "s");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue