#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
This commit is contained in:
Benedek Farkas
2024-12-06 14:14:57 +01:00
committed by GitHub
parent 79f66cebf6
commit ebae790f15
3 changed files with 74 additions and 30 deletions

View File

@@ -72,17 +72,7 @@ namespace Orchard.Projections {
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 @@ namespace Orchard.Projections {
Description = T("The text from the Body part").Text
});
return 6;
return 8;
}
public int UpdateFrom1() {
@@ -343,17 +333,7 @@ namespace Orchard.Projections {
.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)));
@@ -386,5 +366,47 @@ namespace Orchard.Projections {
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");
});
}
}
}
}