You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to update SiteSettings from migration. First problem I have encountered, await siteService.LoadSiteSettingsAsync() throws exception Microsoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'no such table: ContentItemIndex'.'
As I understood, migrations are being run before some of the tables are created. I decided to write this piece of code:
OrchardCore.Settings.ISite siteSettings;
try
{
siteSettings = await siteService.LoadSiteSettingsAsync();
}
catch
{
//if it's first migration, it's possible that SiteSettings are not yet initialized.
//Then, we are creating the settings by ourselves.
siteSettings = new SiteSettings();
}
siteSettings.Alter<LocalizationSettings>("LocalizationSettings", localizationSettings =>
{
localizationSettings.DefaultCulture = "en";
localizationSettings.SupportedCultures = ["ru", "en", "lv"];
});
but if siteService.LoadSiteSettingsAsync is being used, I'm getting such exception (when the migration is already finished)
fail: OrchardCore.Setup.Services.SetupService[0]
Unable to import a recipe during setup.
OrchardCore.Recipes.Models.RecipeExecutionException: The document with Id '3' and type 'OrchardCore.ContentManagement.Metadata.Records.ContentDefinitionRecord, OrchardCore.ContentManagement.Abstractions' could not be updated as it has been changed by another process.
---> YesSql.ConcurrencyException: The document with Id '3' and type 'OrchardCore.ContentManagement.Metadata.Records.ContentDefinitionRecord, OrchardCore.ContentManagement.Abstractions' could not be updated as it has been changed by another process.
at YesSql.Commands.UpdateDocumentCommand.ExecuteAsync(DbConnection connection, DbTransaction transaction, ISqlDialect dialect, ILogger logger)
at YesSql.Session.FlushInternalAsync(Boolean saving)
at YesSql.Session.FlushInternalAsync(Boolean saving)
at YesSql.Services.DefaultQuery.Query`1.FirstOrDefaultImpl()
at OrchardCore.Data.Documents.DocumentStore.GetOrCreateImmutableAsync[T](Func`1 factoryAsync)
at OrchardCore.Documents.DocumentManager`1.GetOrCreateImmutableAsync(Func`1 factoryAsync)
at OrchardCore.Settings.Services.SiteService.GetSiteSettingsAsync()
at OrchardCore.Settings.SiteServiceExtensions.GetSettingsAsync[T](ISiteService siteService)
at OrchardCore.Media.Processing.MediaTokenSettingsUpdater.ActivatedAsync()
at OrchardCore.Environment.Shell.Scope.ShellScope.<>c.<<ActivateShellInternalAsync>b__43_0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.ActivateShellInternalAsync()
at OrchardCore.Environment.Shell.Scope.ShellScope.ActivateShellInternalAsync()
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteStepAsync(RecipeExecutionContext recipeStep)
at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
at OrchardCore.Recipes.Services.RecipeExecutor.ExecuteAsync(String executionId, RecipeDescriptor recipeDescriptor, IDictionary`2 environment, CancellationToken cancellationToken)
at OrchardCore.Setup.Services.SetupService.SetupInternalAsync(SetupContext context)
and
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
YesSql.ConcurrencyException: The document with Id '9' and type 'OrchardCore.ContentManagement.Metadata.Records.ContentDefinitionRecord, OrchardCore.ContentManagement.Abstractions' could not be updated as it has been changed by another process.
at YesSql.Commands.UpdateDocumentCommand.ExecuteAsync(DbConnection connection, DbTransaction transaction, ISqlDialect dialect, ILogger logger)
at YesSql.Session.FlushInternalAsync(Boolean saving)
at YesSql.Session.FlushInternalAsync(Boolean saving)
at YesSql.Services.DefaultQuery.Query`1.FirstOrDefaultImpl()
at OrchardCore.Data.Documents.DocumentStore.GetOrCreateImmutableAsync[T](Func`1 factoryAsync)
at OrchardCore.Documents.DocumentManager`1.GetOrCreateImmutableAsync(Func`1 factoryAsync)
at OrchardCore.Settings.Services.SiteService.GetSiteSettingsAsync()
at OrchardCore.Settings.SiteServiceExtensions.GetSettingsAsync[T](ISiteService siteService)
at OrchardCore.Media.Processing.MediaTokenSettingsUpdater.ActivatedAsync()
at OrchardCore.Environment.Shell.Scope.ShellScope.<>c.<<ActivateShellInternalAsync>b__43_0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.ActivateShellInternalAsync()
at OrchardCore.Environment.Shell.Scope.ShellScope.ActivateShellInternalAsync()
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Setup.Services.SetupService.SetupInternalAsync(SetupContext context)
at OrchardCore.Setup.Services.SetupService.SetupAsync(SetupContext context)
at OrchardCore.Setup.Services.SetupService.SetupAsync(SetupContext context)
at OrchardCore.AutoSetup.AutoSetupMiddleware.SetupTenantAsync(ISetupService setupService, TenantSetupOptions setupOptions, ShellSettings shellSettings)
at OrchardCore.AutoSetup.AutoSetupMiddleware.InvokeAsync(HttpContext httpContext)
at OrchardCore.AutoSetup.AutoSetupMiddleware.InvokeAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at OrchardCore.Modules.ModularTenantRouterMiddleware.Invoke(HttpContext httpContext)
at OrchardCore.Modules.ModularTenantContainerMiddleware.<>c__DisplayClass4_0.<<Invoke>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Environment.Shell.Scope.ShellScope.UsingAsync(Func`2 execute, Boolean activateShell)
at OrchardCore.Modules.ModularTenantContainerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Program.cs:
builder.Services.AddOrchardCms()
.AddSetupFeatures("OrchardCore.AutoSetup")
.EnableFeature("OrchardCore.Contents")
.EnableFeature("OrchardCore.ContentTypes")
.EnableFeature("OrchardCore.Media")
.EnableFeature("OrchardCore.Localization")
.EnableFeature("OrchardCore.ContentLocalization")
.EnableFeature("OrchardCore.Autoroute")
.ConfigureServices(services =>
{
// Custom parts must be registered
services.AddContentPart<IndexPagePart>();
services.AddDataMigration<Migrations>();
});
Orchard Core version
OrchardCore.Application.Cms.Core.Targets 2.1.6
To Reproduce
Create a migration with code I've provided and run it
Expected behavior
siteService.LoadSiteSettingsAsync should not have to break the initial setup
Logs and screenshots
P.S.
Could be useful to have a possibility to run Migrations after all the orchard initialization is complete
The text was updated successfully, but these errors were encountered:
Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. On what happens next, see the docs.
If you like Orchard Core, please star our repo and join our community channels.
C-Coretex
changed the title
When trying to update SiteSettings in migration, getting exception
After loading SiteSettings in migration, exception is being raised
Feb 25, 2025
Ok, siteSettings must be changed at the start of the migration. In my case I just moved the siteService.LoadSiteSettingsAsync to the top and it stopped throwing the exception
Describe the bug
I need to update SiteSettings from migration. First problem I have encountered,
await siteService.LoadSiteSettingsAsync()
throws exceptionMicrosoft.Data.Sqlite.SqliteException: 'SQLite Error 1: 'no such table: ContentItemIndex'.'
As I understood, migrations are being run before some of the tables are created. I decided to write this piece of code:
but if siteService.LoadSiteSettingsAsync is being used, I'm getting such exception (when the migration is already finished)
and
Program.cs:
Orchard Core version
OrchardCore.Application.Cms.Core.Targets 2.1.6
To Reproduce
Create a migration with code I've provided and run it
Expected behavior
siteService.LoadSiteSettingsAsync should not have to break the initial setup
Logs and screenshots
P.S.
Could be useful to have a possibility to run Migrations after all the orchard initialization is complete
The text was updated successfully, but these errors were encountered: