From cb0f965c7fad6faca6738dc963aa4df1fd6e7b62 Mon Sep 17 00:00:00 2001 From: Dao Yu Lai Date: Tue, 31 Dec 2024 22:29:59 -0800 Subject: [PATCH 1/3] MMI-244 Fixed migration issue - regenerated and updated migration files - removed manual create index scripts --- .../1.3.15/Down/PostDown/00-CbraDropIndex.sql | 7 ------- .../1.3.15/Up/PostUp/00-CbraCreateIndex.sql | 11 ----------- .../Migrations/20250101003614_1.3.15.Designer.cs | 6 +++++- libs/net/dal/Migrations/20250101003614_1.3.15.cs | 14 ++++++++++++++ libs/net/dal/Migrations/TNOContextModelSnapshot.cs | 4 ++++ 5 files changed, 23 insertions(+), 19 deletions(-) delete mode 100644 libs/net/dal/Migrations/1.3.15/Down/PostDown/00-CbraDropIndex.sql delete mode 100644 libs/net/dal/Migrations/1.3.15/Up/PostUp/00-CbraCreateIndex.sql 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..14adeaca8 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("20250101062448_1.3.15")] partial class _1315 { /// @@ -1108,6 +1108,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); + b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on"); + + b.HasIndex(new[] { "Status" }, "IX_content_status"); + 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..66be77b4d 100644 --- a/libs/net/dal/Migrations/20250101003614_1.3.15.cs +++ b/libs/net/dal/Migrations/20250101003614_1.3.15.cs @@ -12,7 +12,15 @@ 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"); + migrationBuilder.CreateIndex( + name: "IX_content_status", + table: "content", + column: "status"); PostUp(migrationBuilder); } @@ -20,7 +28,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_status", + table: "content"); PostDown(migrationBuilder); } } diff --git a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs index 2b1798eb5..3327f81ec 100644 --- a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs +++ b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs @@ -1105,6 +1105,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); + b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on"); + + b.HasIndex(new[] { "Status" }, "IX_content_status"); + b.HasIndex(new[] { "Headline" }, "IX_headline"); b.HasIndex(new[] { "Edition", "Section", "Byline" }, "IX_print_content"); From 3e4aa71e561bcf53843f5187491607a5625049b8 Mon Sep 17 00:00:00 2001 From: Dao Yu Lai Date: Wed, 1 Jan 2025 11:04:29 -0800 Subject: [PATCH 2/3] MMI-244 Updated published on index sort --- libs/net/dal/Migrations/20250101003614_1.3.15.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/net/dal/Migrations/20250101003614_1.3.15.cs b/libs/net/dal/Migrations/20250101003614_1.3.15.cs index 66be77b4d..47d192858 100644 --- a/libs/net/dal/Migrations/20250101003614_1.3.15.cs +++ b/libs/net/dal/Migrations/20250101003614_1.3.15.cs @@ -15,7 +15,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_content_published_on", table: "content", - column: "published_on"); + column: "published_on",null,false,null,[true]); migrationBuilder.CreateIndex( name: "IX_content_status", From 041c486e87f01d1ddb9dd9d3bcae3cf721af2fae Mon Sep 17 00:00:00 2001 From: Dao Yu Lai Date: Wed, 1 Jan 2025 20:04:23 -0800 Subject: [PATCH 3/3] MMI-244 Updated indexes - changed the indexes to be (published on and status), and (published on) --- libs/net/dal/Configuration/ContentConfiguration.cs | 6 ++++-- .../dal/Migrations/20250101003614_1.3.15.Designer.cs | 8 +++++--- libs/net/dal/Migrations/20250101003614_1.3.15.cs | 10 ++++++---- libs/net/dal/Migrations/TNOContextModelSnapshot.cs | 6 ++++-- 4 files changed, 19 insertions(+), 11 deletions(-) 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/20250101003614_1.3.15.Designer.cs b/libs/net/dal/Migrations/20250101003614_1.3.15.Designer.cs index 14adeaca8..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("20250101062448_1.3.15")] + [Migration("20250102035724_1.3.15")] partial class _1315 { /// @@ -1108,9 +1108,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); - b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on"); + b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on") + .IsDescending(); - b.HasIndex(new[] { "Status" }, "IX_content_status"); + b.HasIndex(new[] { "PublishedOn", "Status" }, "IX_content_published_on_status") + .IsDescending(true, false); b.HasIndex(new[] { "Headline" }, "IX_headline"); diff --git a/libs/net/dal/Migrations/20250101003614_1.3.15.cs b/libs/net/dal/Migrations/20250101003614_1.3.15.cs index 47d192858..9715f2213 100644 --- a/libs/net/dal/Migrations/20250101003614_1.3.15.cs +++ b/libs/net/dal/Migrations/20250101003614_1.3.15.cs @@ -15,12 +15,14 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_content_published_on", table: "content", - column: "published_on",null,false,null,[true]); + column: "published_on", + descending: new bool[0]); migrationBuilder.CreateIndex( - name: "IX_content_status", + name: "IX_content_published_on_status", table: "content", - column: "status"); + columns: new[] { "published_on", "status" }, + descending: new[] { true, false }); PostUp(migrationBuilder); } @@ -33,7 +35,7 @@ protected override void Down(MigrationBuilder migrationBuilder) table: "content"); migrationBuilder.DropIndex( - name: "IX_content_status", + 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 3327f81ec..c71c8d543 100644 --- a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs +++ b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs @@ -1105,9 +1105,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); - b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on"); + b.HasIndex(new[] { "PublishedOn" }, "IX_content_published_on") + .IsDescending(); - b.HasIndex(new[] { "Status" }, "IX_content_status"); + b.HasIndex(new[] { "PublishedOn", "Status" }, "IX_content_published_on_status") + .IsDescending(true, false); b.HasIndex(new[] { "Headline" }, "IX_headline");