mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(dir): ♻️ make QueryDbContext readonly
This commit is contained in:
parent
1c1fb09e20
commit
d785b940bc
7 changed files with 2818 additions and 2793 deletions
|
|
@ -11,7 +11,7 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Migrations.Migrations
|
||||
{
|
||||
[DbContext(typeof(QueryDbContext))]
|
||||
[Migration("20240601133712_InitialCreate")]
|
||||
[Migration("20240606164416_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
@ -104,7 +104,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("FilterLists");
|
||||
b.ToTable("FilterList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.FilterListLanguage", b =>
|
||||
|
|
@ -209,7 +209,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Languages");
|
||||
b.ToTable("Language");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.License", b =>
|
||||
|
|
@ -249,7 +249,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Licenses");
|
||||
b.ToTable("License");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Maintainer", b =>
|
||||
|
|
@ -282,7 +282,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Maintainers");
|
||||
b.ToTable("Maintainer");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Merge", b =>
|
||||
|
|
@ -377,7 +377,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Syntaxes");
|
||||
b.ToTable("Syntax");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Tag", b =>
|
||||
|
|
@ -401,7 +401,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Tags");
|
||||
b.ToTable("Tag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FilterLists.Directory.Infrastructure.Persistence.Queries.Entities.Dependent", b =>
|
||||
|
|
@ -11,7 +11,7 @@ public partial class InitialCreate : Migration
|
|||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Languages",
|
||||
name: "Language",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<short>(type: "smallint", nullable: false)
|
||||
|
|
@ -21,11 +21,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Languages", x => x.Id);
|
||||
table.PrimaryKey("PK_Language", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Licenses",
|
||||
name: "License",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
|
|
@ -38,11 +38,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Licenses", x => x.Id);
|
||||
table.PrimaryKey("PK_License", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Maintainers",
|
||||
name: "Maintainer",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
|
|
@ -54,7 +54,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Maintainers", x => x.Id);
|
||||
table.PrimaryKey("PK_Maintainer", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
|
|
@ -75,7 +75,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Syntaxes",
|
||||
name: "Syntax",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<short>(type: "smallint", nullable: false)
|
||||
|
|
@ -86,11 +86,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Syntaxes", x => x.Id);
|
||||
table.PrimaryKey("PK_Syntax", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Tags",
|
||||
name: "Tag",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
|
|
@ -100,11 +100,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Tags", x => x.Id);
|
||||
table.PrimaryKey("PK_Tag", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FilterLists",
|
||||
name: "FilterList",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
|
|
@ -124,11 +124,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FilterLists", x => x.Id);
|
||||
table.PrimaryKey("PK_FilterList", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterLists_Licenses_LicenseId",
|
||||
name: "FK_FilterList_License_LicenseId",
|
||||
column: x => x.LicenseId,
|
||||
principalTable: "Licenses",
|
||||
principalTable: "License",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
|
@ -150,9 +150,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SoftwareSyntax_Syntaxes_SyntaxId",
|
||||
name: "FK_SoftwareSyntax_Syntax_SyntaxId",
|
||||
column: x => x.SyntaxId,
|
||||
principalTable: "Syntaxes",
|
||||
principalTable: "Syntax",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -168,15 +168,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_Dependent", x => new { x.DependencyFilterListId, x.DependentFilterListId });
|
||||
table.ForeignKey(
|
||||
name: "FK_Dependent_FilterLists_DependencyFilterListId",
|
||||
name: "FK_Dependent_FilterList_DependencyFilterListId",
|
||||
column: x => x.DependencyFilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Dependent_FilterLists_DependentFilterListId",
|
||||
name: "FK_Dependent_FilterList_DependentFilterListId",
|
||||
column: x => x.DependentFilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
|
|
@ -191,15 +191,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_FilterListLanguage", x => new { x.FilterListId, x.LanguageId });
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListLanguage_FilterLists_FilterListId",
|
||||
name: "FK_FilterListLanguage_FilterList_FilterListId",
|
||||
column: x => x.FilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListLanguage_Languages_LanguageId",
|
||||
name: "FK_FilterListLanguage_Language_LanguageId",
|
||||
column: x => x.LanguageId,
|
||||
principalTable: "Languages",
|
||||
principalTable: "Language",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -215,15 +215,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_FilterListMaintainer", x => new { x.FilterListId, x.MaintainerId });
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListMaintainer_FilterLists_FilterListId",
|
||||
name: "FK_FilterListMaintainer_FilterList_FilterListId",
|
||||
column: x => x.FilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListMaintainer_Maintainers_MaintainerId",
|
||||
name: "FK_FilterListMaintainer_Maintainer_MaintainerId",
|
||||
column: x => x.MaintainerId,
|
||||
principalTable: "Maintainers",
|
||||
principalTable: "Maintainer",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -239,15 +239,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_FilterListSyntax", x => new { x.FilterListId, x.SyntaxId });
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListSyntax_FilterLists_FilterListId",
|
||||
name: "FK_FilterListSyntax_FilterList_FilterListId",
|
||||
column: x => x.FilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListSyntax_Syntaxes_SyntaxId",
|
||||
name: "FK_FilterListSyntax_Syntax_SyntaxId",
|
||||
column: x => x.SyntaxId,
|
||||
principalTable: "Syntaxes",
|
||||
principalTable: "Syntax",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -263,15 +263,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_FilterListTag", x => new { x.FilterListId, x.TagId });
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListTag_FilterLists_FilterListId",
|
||||
name: "FK_FilterListTag_FilterList_FilterListId",
|
||||
column: x => x.FilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListTag_Tags_TagId",
|
||||
name: "FK_FilterListTag_Tag_TagId",
|
||||
column: x => x.TagId,
|
||||
principalTable: "Tags",
|
||||
principalTable: "Tag",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -291,9 +291,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_FilterListViewUrl", x => new { x.FilterListId, x.Id });
|
||||
table.ForeignKey(
|
||||
name: "FK_FilterListViewUrl_FilterLists_FilterListId",
|
||||
name: "FK_FilterListViewUrl_FilterList_FilterListId",
|
||||
column: x => x.FilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -309,14 +309,14 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_Fork", x => new { x.UpstreamFilterListId, x.ForkFilterListId });
|
||||
table.ForeignKey(
|
||||
name: "FK_Fork_FilterLists_ForkFilterListId",
|
||||
name: "FK_Fork_FilterList_ForkFilterListId",
|
||||
column: x => x.ForkFilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Fork_FilterLists_UpstreamFilterListId",
|
||||
name: "FK_Fork_FilterList_UpstreamFilterListId",
|
||||
column: x => x.UpstreamFilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
|
@ -332,15 +332,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
{
|
||||
table.PrimaryKey("PK_Merge", x => new { x.IncludedInFilterListId, x.IncludesFilterListId });
|
||||
table.ForeignKey(
|
||||
name: "FK_Merge_FilterLists_IncludedInFilterListId",
|
||||
name: "FK_Merge_FilterList_IncludedInFilterListId",
|
||||
column: x => x.IncludedInFilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Merge_FilterLists_IncludesFilterListId",
|
||||
name: "FK_Merge_FilterList_IncludesFilterListId",
|
||||
column: x => x.IncludesFilterListId,
|
||||
principalTable: "FilterLists",
|
||||
principalTable: "FilterList",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
|
|
@ -349,6 +349,17 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
table: "Dependent",
|
||||
column: "DependentFilterListId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FilterList_LicenseId",
|
||||
table: "FilterList",
|
||||
column: "LicenseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FilterList_Name",
|
||||
table: "FilterList",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FilterListLanguage_LanguageId",
|
||||
table: "FilterListLanguage",
|
||||
|
|
@ -359,17 +370,6 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
table: "FilterListMaintainer",
|
||||
column: "MaintainerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FilterLists_LicenseId",
|
||||
table: "FilterLists",
|
||||
column: "LicenseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FilterLists_Name",
|
||||
table: "FilterLists",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FilterListSyntax_SyntaxId",
|
||||
table: "FilterListSyntax",
|
||||
|
|
@ -392,26 +392,26 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
column: "ForkFilterListId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Languages_Iso6391",
|
||||
table: "Languages",
|
||||
name: "IX_Language_Iso6391",
|
||||
table: "Language",
|
||||
column: "Iso6391",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Languages_Name",
|
||||
table: "Languages",
|
||||
name: "IX_Language_Name",
|
||||
table: "Language",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Licenses_Name",
|
||||
table: "Licenses",
|
||||
name: "IX_License_Name",
|
||||
table: "License",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Maintainers_Name",
|
||||
table: "Maintainers",
|
||||
name: "IX_Maintainer_Name",
|
||||
table: "Maintainer",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
|
|
@ -432,14 +432,14 @@ protected override void Up(MigrationBuilder migrationBuilder)
|
|||
column: "SyntaxId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Syntaxes_Name",
|
||||
table: "Syntaxes",
|
||||
name: "IX_Syntax_Name",
|
||||
table: "Syntax",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Tags_Name",
|
||||
table: "Tags",
|
||||
name: "IX_Tag_Name",
|
||||
table: "Tag",
|
||||
column: "Name",
|
||||
unique: true);
|
||||
}
|
||||
|
|
@ -475,25 +475,25 @@ protected override void Down(MigrationBuilder migrationBuilder)
|
|||
name: "SoftwareSyntax");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Languages");
|
||||
name: "Language");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Maintainers");
|
||||
name: "Maintainer");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Tags");
|
||||
name: "Tag");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "FilterLists");
|
||||
name: "FilterList");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Software");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Syntaxes");
|
||||
name: "Syntax");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Licenses");
|
||||
name: "License");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
namespace FilterLists.Directory.Infrastructure.Migrations.Migrations
|
||||
{
|
||||
[DbContext(typeof(QueryDbContext))]
|
||||
[Migration("20240601231119_InitialSeedData")]
|
||||
[Migration("20240606164524_InitialSeedData")]
|
||||
partial class InitialSeedData
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
@ -151,7 +151,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("FilterLists");
|
||||
b.ToTable("FilterList");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -58509,7 +58509,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Languages");
|
||||
b.ToTable("Language");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -59631,7 +59631,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Licenses");
|
||||
b.ToTable("License");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -60056,7 +60056,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Maintainers");
|
||||
b.ToTable("Maintainer");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -63052,7 +63052,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Syntaxes");
|
||||
b.ToTable("Syntax");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -63340,7 +63340,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Tags");
|
||||
b.ToTable("Tag");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -148,7 +148,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("FilterLists");
|
||||
b.ToTable("FilterList");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -58506,7 +58506,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Languages");
|
||||
b.ToTable("Language");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -59628,7 +59628,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Licenses");
|
||||
b.ToTable("License");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -60053,7 +60053,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Maintainers");
|
||||
b.ToTable("Maintainer");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -63049,7 +63049,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Syntaxes");
|
||||
b.ToTable("Syntax");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
@ -63337,7 +63337,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
|
|||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Tags");
|
||||
b.ToTable("Tag");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
|
|
|
|||
|
|
@ -10,10 +10,6 @@ public static void AddInfrastructure(this IHostApplicationBuilder builder)
|
|||
{
|
||||
builder.AddSqlServerDbContext<QueryDbContext>("directorydb",
|
||||
_ => { },
|
||||
o =>
|
||||
{
|
||||
o.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
||||
o.UseSqlServer(so => so.MigrationsAssembly("FilterLists.Directory.Infrastructure.Migrations"));
|
||||
});
|
||||
o => o.UseSqlServer(so => so.MigrationsAssembly("FilterLists.Directory.Infrastructure.Migrations")));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,22 +3,51 @@
|
|||
|
||||
namespace FilterLists.Directory.Infrastructure.Persistence.Queries.Context;
|
||||
|
||||
// TODO: explicitly make more readonly-ish
|
||||
public sealed class QueryDbContext(DbContextOptions<QueryDbContext> options) : DbContext(options)
|
||||
public sealed class QueryDbContext : DbContext
|
||||
{
|
||||
public DbSet<FilterList> FilterLists => Set<FilterList>();
|
||||
public DbSet<Language> Languages => Set<Language>();
|
||||
public DbSet<License> Licenses => Set<License>();
|
||||
public DbSet<Maintainer> Maintainers => Set<Maintainer>();
|
||||
public DbSet<Software> Software => Set<Software>();
|
||||
public DbSet<Syntax> Syntaxes => Set<Syntax>();
|
||||
public DbSet<Tag> Tags => Set<Tag>();
|
||||
private const string ReadOnlyErrorMessage = "This context is read-only and cannot save changes.";
|
||||
|
||||
public QueryDbContext(DbContextOptions<QueryDbContext> options) : base(options)
|
||||
{
|
||||
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
|
||||
}
|
||||
|
||||
public IQueryable<FilterList> FilterLists => Set<FilterList>();
|
||||
public IQueryable<Language> Languages => Set<Language>();
|
||||
public IQueryable<License> Licenses => Set<License>();
|
||||
public IQueryable<Maintainer> Maintainers => Set<Maintainer>();
|
||||
public IQueryable<Software> Software => Set<Software>();
|
||||
public IQueryable<Syntax> Syntaxes => Set<Syntax>();
|
||||
public IQueryable<Tag> Tags => Set<Tag>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.UseCollation("Latin1_General_100_CI_AS_SC");
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(
|
||||
GetType().Assembly,
|
||||
type => type.Namespace == typeof(FilterListTypeConfiguration).Namespace);
|
||||
}
|
||||
|
||||
public override int SaveChanges()
|
||||
{
|
||||
throw new InvalidOperationException(ReadOnlyErrorMessage);
|
||||
}
|
||||
|
||||
public override int SaveChanges(bool acceptAllChangesOnSuccess)
|
||||
{
|
||||
throw new InvalidOperationException(ReadOnlyErrorMessage);
|
||||
}
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new InvalidOperationException(ReadOnlyErrorMessage);
|
||||
}
|
||||
|
||||
public override Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new InvalidOperationException(ReadOnlyErrorMessage);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue