Skip to content

Commit

Permalink
Upgrade YesSql to 4.0.0-beta-0003 (OrchardCMS#14700)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored and urbanit committed Mar 18, 2024
1 parent b1a8bd4 commit d6a9cdd
Show file tree
Hide file tree
Showing 69 changed files with 583 additions and 480 deletions.
10 changes: 5 additions & 5 deletions src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
<PackageManagement Include="xunit" Version="2.6.3" />
<PackageManagement Include="xunit.analyzers" Version="1.7.0" />
<PackageManagement Include="xunit.runner.visualstudio" Version="2.5.5" />
<PackageManagement Include="YesSql" Version="3.5.0" />
<PackageManagement Include="YesSql.Abstractions" Version="3.5.0" />
<PackageManagement Include="YesSql.Core" Version="3.5.0" />
<PackageManagement Include="YesSql.Filters.Abstractions" Version="3.5.0" />
<PackageManagement Include="YesSql.Filters.Query" Version="3.5.0" />
<PackageManagement Include="YesSql" Version="4.0.0-beta-0003" />
<PackageManagement Include="YesSql.Abstractions" Version="4.0.0-beta-0003" />
<PackageManagement Include="YesSql.Core" Version="4.0.0-beta-0003" />
<PackageManagement Include="YesSql.Filters.Abstractions" Version="4.0.0-beta-0003" />
<PackageManagement Include="YesSql.Filters.Query" Version="4.0.0-beta-0003" />
<PackageManagement Include="ZString" Version="2.5.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part

contentItem.Apply(dashboardPart);

_session.Save(contentItem);
await _session.SaveAsync(contentItem);

if (contentItem.IsPublished() == false)
{
Expand All @@ -189,7 +189,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part
publishedMetaData.Width = partViewModel.Width;
publishedMetaData.Height = partViewModel.Height;
publishedVersion.Apply(publishedMetaData);
_session.Save(publishedVersion);
await _session.SaveAsync(publishedVersion);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public Migrations(IContentDefinitionManager contentDefinitionManager, IRecipeMig

public async Task<int> CreateAsync()
{
SchemaBuilder.CreateMapIndexTable<DashboardPartIndex>(table => table
await SchemaBuilder.CreateMapIndexTableAsync<DashboardPartIndex>(table => table
.Column<double>("Position")
);

SchemaBuilder.AlterIndexTable<DashboardPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<DashboardPartIndex>(table => table
.CreateIndex("IDX_DashboardPart_DocumentId",
"DocumentId",
"Position")
Expand All @@ -51,9 +51,9 @@ public async Task<int> UpdateFrom1Async()
}

// This code can be removed in a later version.
public int UpdateFrom2()
public async Task<int> UpdateFrom2Async()
{
SchemaBuilder.AlterIndexTable<DashboardPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<DashboardPartIndex>(table => table
.CreateIndex("IDX_DashboardPart_DocumentId",
"DocumentId",
"Position")
Expand Down
18 changes: 9 additions & 9 deletions src/OrchardCore.Modules/OrchardCore.Alias/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(AliasPart), buil
.Attachable()
.WithDescription("Provides a way to define custom aliases for content items."));

SchemaBuilder.CreateMapIndexTable<AliasPartIndex>(table => table
await SchemaBuilder.CreateMapIndexTableAsync<AliasPartIndex>(table => table
.Column<string>("Alias", col => col.WithLength(AliasPart.MaxAliasLength))
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<bool>("Latest", c => c.WithDefault(false))
.Column<bool>("Published", c => c.WithDefault(true))
);

SchemaBuilder.AlterIndexTable<AliasPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
.CreateIndex("IDX_AliasPartIndex_DocumentId",
"DocumentId",
"Alias",
Expand All @@ -44,24 +44,24 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(AliasPart), buil
}

// This code can be removed in a later version as Latest and Published are alterations.
public int UpdateFrom1()
public async Task<int> UpdateFrom1Async()
{
SchemaBuilder.AlterIndexTable<AliasPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
.AddColumn<bool>("Latest", c => c.WithDefault(false))
);

SchemaBuilder.AlterIndexTable<AliasPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
.AddColumn<bool>("Published", c => c.WithDefault(true))
);

return 2;
}

// This code can be removed in a later version.
public int UpdateFrom2()
public async Task<int> UpdateFrom2Async()
{
// Can't be fully created on existing databases where the 'Alias' may be of 767 chars.
SchemaBuilder.AlterIndexTable<AliasPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
//.CreateIndex("IDX_AliasPartIndex_DocumentId",
// "DocumentId",
// "Alias",
Expand All @@ -78,11 +78,11 @@ public int UpdateFrom2()
}

// This code can be removed in a later version.
public int UpdateFrom3()
public async Task<int> UpdateFrom3Async()
{
// In the previous migration step, an index was not fully created,
// but here, we can create a separate one for the missing columns.
SchemaBuilder.AlterIndexTable<AliasPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
.CreateIndex("IDX_AliasPartIndex_DocumentId_ContentItemId",
"DocumentId",
"ContentItemId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(ArchiveLaterPart
.Attachable()
.WithDescription("Adds the ability to schedule content items to be archived at a given future date and time."));

SchemaBuilder.CreateMapIndexTable<ArchiveLaterPartIndex>(table => table
await SchemaBuilder.CreateMapIndexTableAsync<ArchiveLaterPartIndex>(table => table
.Column<string>("ContentItemId")
.Column<DateTime>("ScheduledArchiveDateTimeUtc")
.Column<bool>("Published")
.Column<bool>("Latest")
);

SchemaBuilder.AlterIndexTable<ArchiveLaterPartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<ArchiveLaterPartIndex>(table => table
.CreateIndex("IDX_ArchiveLaterPartIndex_DocumentId",
"Id",
"DocumentId",
Expand Down
7 changes: 4 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.AuditTrail/Migrations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using OrchardCore.AuditTrail.Indexes;
using OrchardCore.AuditTrail.Models;
using OrchardCore.Data.Migration;
Expand All @@ -8,9 +9,9 @@ namespace OrchardCore.AuditTrail
{
public class Migrations : DataMigration
{
public int Create()
public async Task<int> CreateAsync()
{
SchemaBuilder.CreateMapIndexTable<AuditTrailEventIndex>(table => table
await SchemaBuilder.CreateMapIndexTableAsync<AuditTrailEventIndex>(table => table
.Column<string>(nameof(AuditTrailEventIndex.EventId), column => column.WithLength(26))
.Column<string>(nameof(AuditTrailEventIndex.Category), column => column.WithLength(64))
.Column<string>(nameof(AuditTrailEventIndex.Name), column => column.WithLength(64))
Expand All @@ -20,7 +21,7 @@ public int Create()
.Column<DateTime>(nameof(AuditTrailEventIndex.CreatedUtc), column => column.Nullable()),
collection: AuditTrailEvent.Collection);

SchemaBuilder.AlterIndexTable<AuditTrailEventIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AuditTrailEventIndex>(table => table
.CreateIndex("IDX_AuditTrailEventIndex_DocumentId",
"DocumentId",
"EventId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public AuditTrailManager(

await _auditTrailEventHandlers.InvokeAsync((handler, context, auditTrailEvent) => handler.AlterAsync(context, auditTrailEvent), createContext, auditTrailEvent, _logger);

_session.Save(auditTrailEvent, AuditTrailEvent.Collection);
await _session.SaveAsync(auditTrailEvent, AuditTrailEvent.Collection);
}
public Task<AuditTrailEvent> GetEventAsync(string eventId) =>
_session.Query<AuditTrailEvent, AuditTrailEventIndex>(collection: AuditTrailEvent.Collection)
Expand Down
10 changes: 5 additions & 5 deletions src/OrchardCore.Modules/OrchardCore.Autoroute/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync("AutoroutePart", builde
.Attachable()
.WithDescription("Provides a custom url for your content item."));

SchemaBuilder.CreateMapIndexTable<AutoroutePartIndex>(table => table
await SchemaBuilder.CreateMapIndexTableAsync<AutoroutePartIndex>(table => table
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<string>("ContainedContentItemId", c => c.WithLength(26))
.Column<string>("JsonPath", c => c.Unlimited())
Expand Down Expand Up @@ -54,17 +54,17 @@ public int UpdateFrom2()
}

// This code can be removed in a later version.
public int UpdateFrom3()
public async Task<int> UpdateFrom3Async()
{
SchemaBuilder.AlterIndexTable<AutoroutePartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AutoroutePartIndex>(table => table
.AddColumn<string>("ContainedContentItemId", c => c.WithLength(26))
);

SchemaBuilder.AlterIndexTable<AutoroutePartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AutoroutePartIndex>(table => table
.AddColumn<string>("JsonPath", c => c.Unlimited())
);

SchemaBuilder.AlterIndexTable<AutoroutePartIndex>(table => table
await SchemaBuilder.AlterIndexTableAsync<AutoroutePartIndex>(table => table
.AddColumn<bool>("Latest", c => c.WithDefault(false))
);

Expand Down
Loading

0 comments on commit d6a9cdd

Please sign in to comment.