Skip to content

Commit

Permalink
#8276: Updating Npgsql to 4.0.17 and fixing setup with PostgreSQL (#8810
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
BenedekFarkas authored Dec 6, 2024
1 parent 79f66ce commit ebae790
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 30 deletions.
70 changes: 46 additions & 24 deletions src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -287,7 +277,7 @@ public int Create() {
Description = T("The text from the Body part").Text
});

return 6;
return 8;
}

public int UpdateFrom1() {
Expand Down Expand Up @@ -343,17 +333,7 @@ public int UpdateFrom4() {
.AddColumn<decimal>("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<string>("VersionScope", c => c.WithLength(15)));
Expand Down Expand Up @@ -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");
});
}
}
}
}
26 changes: 21 additions & 5 deletions src/Orchard.Web/Orchard.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,14 @@
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.2.2.3\lib\net45\Mono.Security.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=6.7.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.6.7.9\lib\net45\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Npgsql, Version=2.2.3.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.2.2.3\lib\net45\Npgsql.dll</HintPath>
<Reference Include="Npgsql, Version=4.0.17.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL">
<HintPath>..\packages\Npgsql.4.0.17\lib\net451\Npgsql.dll</HintPath>
</Reference>
<Reference Include="NuGet.Core, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Orchard.NuGet.Core.1.1.0.0\lib\NuGet.Core.dll</HintPath>
Expand All @@ -91,6 +88,9 @@
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
Expand All @@ -100,7 +100,23 @@
<HintPath>..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
Expand Down
8 changes: 7 additions & 1 deletion src/Orchard.Web/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
<package id="MySql.Data" version="6.7.9" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Npgsql" version="2.2.3" targetFramework="net48" />
<package id="Npgsql" version="4.0.17" targetFramework="net48" />
<package id="Orchard.NuGet.Core" version="1.1.0.0" targetFramework="net48" />
<package id="Owin" version="1.0" targetFramework="net48" />
<package id="System.Buffers" version="4.4.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.3" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>

0 comments on commit ebae790

Please sign in to comment.