From ebae790f15b68cdfad172e3661d7a19924591dce Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Fri, 6 Dec 2024 14:14:57 +0100 Subject: [PATCH] #8276: Updating Npgsql to 4.0.17 and fixing setup with PostgreSQL (#8810) * Updating Npgsql to version 4.0.17 (the latest minor version of the closest major version that isn't vulnerable) https://github.com/OrchardCMS/Orchard/security/dependabot/54 * Fixing that Projection Migrations created indexes with the same name in different tables, which is not supported by PostgreSQL --- .../Modules/Orchard.Projections/Migrations.cs | 70 ++++++++++++------- src/Orchard.Web/Orchard.Web.csproj | 26 +++++-- src/Orchard.Web/packages.config | 8 ++- 3 files changed, 74 insertions(+), 30 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs index cf0b6f57e16..fbcc658ed0a 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs @@ -72,17 +72,7 @@ public int Create() { SchemaBuilder.CreateTable("FieldIndexPartRecord", table => table.ContentPartRecord()); //Adds indexes for better performances in queries - SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); - - SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); - - SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); - - SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); + AddPropertyNameAndFieldIndexPartRecordIdIndexes(); // Query @@ -287,7 +277,7 @@ public int Create() { Description = T("The text from the Body part").Text }); - return 6; + return 8; } public int UpdateFrom1() { @@ -343,17 +333,7 @@ public int UpdateFrom4() { .AddColumn("LatestValue")); //Adds indexes for better performances in queries - SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); - - SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); - - SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); - - SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" })); - SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" })); + AddPropertyNameAndFieldIndexPartRecordIdIndexes(); SchemaBuilder.AlterTable("QueryPartRecord", table => table .AddColumn("VersionScope", c => c.WithLength(15))); @@ -386,5 +366,47 @@ public int UpdateFrom6() { return 7; } + + public int UpdateFrom7() { + SchemaBuilder.AlterTable("StringFieldIndexRecord", table => { + table.DropIndex("IX_PropertyName"); + table.DropIndex("IX_FieldIndexPartRecord_Id"); + }); + SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => { + table.DropIndex("IX_PropertyName"); + table.DropIndex("IX_FieldIndexPartRecord_Id"); + }); + SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => { + table.DropIndex("IX_PropertyName"); + table.DropIndex("IX_FieldIndexPartRecord_Id"); + }); + SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => { + table.DropIndex("IX_PropertyName"); + table.DropIndex("IX_FieldIndexPartRecord_Id"); + }); + + AddPropertyNameAndFieldIndexPartRecordIdIndexes(); + + return 8; + } + + private void AddPropertyNameAndFieldIndexPartRecordIdIndexes() { + SchemaBuilder.AlterTable("StringFieldIndexRecord", table => { + table.CreateIndex("IDX_StringFieldIndexRecord_PropertyName", "PropertyName"); + table.CreateIndex("IDX_StringFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id"); + }); + SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => { + table.CreateIndex("IDX_IntegerFieldIndexRecord_PropertyName", "PropertyName"); + table.CreateIndex("IDX_IntegerFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id"); + }); + SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => { + table.CreateIndex("IDX_DoubleFieldIndexRecord_PropertyName", "PropertyName"); + table.CreateIndex("IDX_DoubleFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id"); + }); + SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => { + table.CreateIndex("IDX_DecimalFieldIndexRecord_PropertyName", "PropertyName"); + table.CreateIndex("IDX_DecimalFieldIndexRecord_FieldIndexPartRecord_Id", "FieldIndexPartRecord_Id"); + }); + } } -} \ No newline at end of file +} diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 563f9d6babd..cf56d91b1a5 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -72,17 +72,14 @@ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - ..\packages\Npgsql.2.2.3\lib\net45\Mono.Security.dll - ..\packages\MySql.Data.6.7.9\lib\net45\MySql.Data.dll ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\packages\Npgsql.2.2.3\lib\net45\Npgsql.dll + + ..\packages\Npgsql.4.0.17\lib\net451\Npgsql.dll ..\packages\Orchard.NuGet.Core.1.1.0.0\lib\NuGet.Core.dll @@ -91,6 +88,9 @@ ..\packages\Owin.1.0\lib\net40\Owin.dll + + ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + 3.5 @@ -100,7 +100,23 @@ ..\..\lib\sqlce\System.Data.SqlServerCe.dll True + + ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + diff --git a/src/Orchard.Web/packages.config b/src/Orchard.Web/packages.config index a3cf9084f72..750cc0a6259 100644 --- a/src/Orchard.Web/packages.config +++ b/src/Orchard.Web/packages.config @@ -11,7 +11,13 @@ - + + + + + + + \ No newline at end of file