mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(directory): ♻ abandon owned FilterListViewUrl config due to seeding limitation
This commit is contained in:
parent
abb5700544
commit
f19bf76544
5 changed files with 103 additions and 91 deletions
|
|
@ -10,7 +10,7 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Migrations.Migrations
|
||||
{
|
||||
[DbContext(typeof(QueryDbContext))]
|
||||
[Migration("20200828001720_Initial")]
|
||||
[Migration("20200828005349_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
|
|
@ -147,6 +147,38 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.ToTable("FilterListTags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListViewUrl", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<short>("Primariness")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b.Property<short>("SegmentNumber")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FilterListId", "SegmentNumber", "Primariness")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("FilterListViewUrls");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Fork", b =>
|
||||
{
|
||||
b.Property<int>("UpstreamFilterListId")
|
||||
|
|
@ -344,41 +376,6 @@ 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.FilterListViewUrl", "ViewUrls", b1 =>
|
||||
{
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b1.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<short>("Primariness")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b1.Property<short>("SegmentNumber")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b1.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("FilterListId", "SegmentNumber", "Primariness")
|
||||
.IsUnique();
|
||||
|
||||
b1.ToTable("FilterListViewUrls");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("FilterListId");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListLanguage", b =>
|
||||
|
|
@ -441,6 +438,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListViewUrl", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "FilterList")
|
||||
.WithMany("ViewUrls")
|
||||
.HasForeignKey("FilterListId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Fork", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "ForkFilterList")
|
||||
|
|
@ -276,10 +276,10 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FilterListId = table.Column<int>(nullable: false),
|
||||
SegmentNumber = table.Column<short>(nullable: false, defaultValue: (short)1),
|
||||
Primariness = table.Column<short>(nullable: false, defaultValue: (short)1),
|
||||
Url = table.Column<string>(nullable: false),
|
||||
FilterListId = table.Column<int>(nullable: false)
|
||||
Url = table.Column<string>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
|
|
@ -145,6 +145,38 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.ToTable("FilterListTags");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListViewUrl", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<short>("Primariness")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b.Property<short>("SegmentNumber")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FilterListId", "SegmentNumber", "Primariness")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("FilterListViewUrls");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Fork", b =>
|
||||
{
|
||||
b.Property<int>("UpstreamFilterListId")
|
||||
|
|
@ -342,41 +374,6 @@ 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.FilterListViewUrl", "ViewUrls", b1 =>
|
||||
{
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b1.Property<int>("FilterListId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<short>("Primariness")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b1.Property<short>("SegmentNumber")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("smallint")
|
||||
.HasDefaultValue((short)1);
|
||||
|
||||
b1.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b1.HasKey("Id");
|
||||
|
||||
b1.HasIndex("FilterListId", "SegmentNumber", "Primariness")
|
||||
.IsUnique();
|
||||
|
||||
b1.ToTable("FilterListViewUrls");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("FilterListId");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListLanguage", b =>
|
||||
|
|
@ -439,6 +436,15 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListViewUrl", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "FilterList")
|
||||
.WithMany("ViewUrls")
|
||||
.HasForeignKey("FilterListId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Fork", b =>
|
||||
{
|
||||
b.HasOne("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterList", "ForkFilterList")
|
||||
|
|
|
|||
|
|
@ -40,24 +40,6 @@ internal class FilterListTypeConfiguration : IEntityTypeConfiguration<FilterList
|
|||
public virtual void Configure(EntityTypeBuilder<FilterList> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
builder.OwnsMany(fl => fl.ViewUrls,
|
||||
o =>
|
||||
{
|
||||
o.ToTable(nameof(FilterListViewUrl) + "s");
|
||||
const string id = "Id";
|
||||
o.Property<int>(id);
|
||||
o.HasKey(id);
|
||||
const string filterListId = nameof(FilterList) + id;
|
||||
o.Property<int>(filterListId);
|
||||
o.Property(u => u.SegmentNumber).HasDefaultValue(1);
|
||||
o.Property(u => u.Primariness).HasDefaultValue(1);
|
||||
o.HasIndex(
|
||||
filterListId,
|
||||
nameof(FilterListViewUrl.SegmentNumber),
|
||||
nameof(FilterListViewUrl.Primariness))
|
||||
.IsUnique();
|
||||
})
|
||||
.HasDataJsonFile<FilterListViewUrl>();
|
||||
builder.HasDataJsonFile<FilterList>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,29 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Entities
|
||||
{
|
||||
public class FilterListViewUrl
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int FilterListId { get; set; }
|
||||
public FilterList FilterList { get; set; } = null!;
|
||||
public short SegmentNumber { get; set; }
|
||||
public short Primariness { get; set; }
|
||||
public Uri Url { get; set; } = null!;
|
||||
}
|
||||
|
||||
internal class FilterListViewUrlConfiguration : IEntityTypeConfiguration<FilterListViewUrl>
|
||||
{
|
||||
public virtual void Configure(EntityTypeBuilder<FilterListViewUrl> builder)
|
||||
{
|
||||
_ = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
builder.ToTable(nameof(FilterListViewUrl) + "s");
|
||||
builder.Property(u => u.SegmentNumber).HasDefaultValue(1);
|
||||
builder.Property(u => u.Primariness).HasDefaultValue(1);
|
||||
builder.HasIndex(u => new {u.FilterListId, u.SegmentNumber, u.Primariness}).IsUnique();
|
||||
builder.HasDataJsonFile<FilterListViewUrl>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue