diff --git a/libs/net/dal/Configuration/ContentConfiguration.cs b/libs/net/dal/Configuration/ContentConfiguration.cs index afd19051e..ac542a1d4 100644 --- a/libs/net/dal/Configuration/ContentConfiguration.cs +++ b/libs/net/dal/Configuration/ContentConfiguration.cs @@ -52,8 +52,10 @@ public override void Configure(EntityTypeBuilder builder) builder.HasIndex(m => new { m.ContentType, m.OtherSource, m.Uid, m.Page, m.Status, m.IsHidden }, "IX_content"); builder.HasIndex(m => new { m.Edition, m.Section, m.Byline }, "IX_print_content"); builder.HasIndex(m => m.Headline, "IX_headline"); - builder.HasIndex(m => m.PublishedOn, "IX_content_published_on"); - builder.HasIndex(m => m.Status, "IX_content_status"); + builder.HasIndex(m => new { m.PublishedOn, m.Status }, "IX_content_published_on_status") + .IsDescending(true, false); + builder.HasIndex(m => m.PublishedOn, "IX_content_published_on") + .IsDescending(true); base.Configure(builder); } diff --git a/libs/net/dal/Migrations/1.3.15/Down/PostDown/00-CbraDropIndex.sql b/libs/net/dal/Migrations/1.3.15/Down/PostDown/00-CbraDropIndex.sql deleted file mode 100644 index 7aa145bab..000000000 --- a/libs/net/dal/Migrations/1.3.15/Down/PostDown/00-CbraDropIndex.sql +++ /dev/null @@ -1,7 +0,0 @@ -DO $$ -BEGIN - -DROP INDEX IF EXISTS public."IX_content_published_on"; -DROP INDEX IF EXISTS public."IX_content_status"; - -END $$; diff --git a/libs/net/dal/Migrations/1.3.15/Up/PostUp/00-CbraCreateIndex.sql b/libs/net/dal/Migrations/1.3.15/Up/PostUp/00-CbraCreateIndex.sql deleted file mode 100644 index 27349278e..000000000 --- a/libs/net/dal/Migrations/1.3.15/Up/PostUp/00-CbraCreateIndex.sql +++ /dev/null @@ -1,11 +0,0 @@ -DO $$ -BEGIN - -CREATE INDEX IF NOT EXISTS "IX_content_published_on" - ON public.content USING btree - (published_on DESC); -CREATE INDEX IF NOT EXISTS "IX_content_status" - ON public.content USING btree - (status ASC); - -END $$; diff --git a/libs/net/dal/Migrations/20250101003614_1.3.15.Designer.cs b/libs/net/dal/Migrations/20250101003614_1.3.15.Designer.cs index a31f4b602..57999d49b 100644 --- a/libs/net/dal/Migrations/20250101003614_1.3.15.Designer.cs +++ b/libs/net/dal/Migrations/20250101003614_1.3.15.Designer.cs @@ -15,7 +15,7 @@ namespace TNO.DAL.Migrations { [DbContext(typeof(TNOContext))] - [Migration("20250101003614_1.3.15")] + [Migration("20250102035724_1.3.15")] partial class _1315 { /// @@ -1108,6 +1108,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); + b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on") + .IsDescending(); + + b.HasIndex(new[] { "PublishedOn", "Status" }, "IX_content_published_on_status") + .IsDescending(true, false); + b.HasIndex(new[] { "Headline" }, "IX_headline"); b.HasIndex(new[] { "Edition", "Section", "Byline" }, "IX_print_content"); diff --git a/libs/net/dal/Migrations/20250101003614_1.3.15.cs b/libs/net/dal/Migrations/20250101003614_1.3.15.cs index 579da61e0..9715f2213 100644 --- a/libs/net/dal/Migrations/20250101003614_1.3.15.cs +++ b/libs/net/dal/Migrations/20250101003614_1.3.15.cs @@ -12,7 +12,17 @@ public partial class _1315 : SeedMigration protected override void Up(MigrationBuilder migrationBuilder) { PreUp(migrationBuilder); + migrationBuilder.CreateIndex( + name: "IX_content_published_on", + table: "content", + column: "published_on", + descending: new bool[0]); + migrationBuilder.CreateIndex( + name: "IX_content_published_on_status", + table: "content", + columns: new[] { "published_on", "status" }, + descending: new[] { true, false }); PostUp(migrationBuilder); } @@ -20,7 +30,13 @@ protected override void Up(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder) { PreDown(migrationBuilder); + migrationBuilder.DropIndex( + name: "IX_content_published_on", + table: "content"); + migrationBuilder.DropIndex( + name: "IX_content_published_on_status", + table: "content"); PostDown(migrationBuilder); } } diff --git a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs index 2b1798eb5..c71c8d543 100644 --- a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs +++ b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs @@ -1105,6 +1105,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); + b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on") + .IsDescending(); + + b.HasIndex(new[] { "PublishedOn", "Status" }, "IX_content_published_on_status") + .IsDescending(true, false); + b.HasIndex(new[] { "Headline" }, "IX_headline"); b.HasIndex(new[] { "Edition", "Section", "Byline" }, "IX_print_content");