diff --git a/backend/src/Squidex.Domain.Apps.Entities/DomainObjectState.cs b/backend/src/Squidex.Domain.Apps.Entities/DomainObjectState.cs index 88643a701..133d3fa4f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/DomainObjectState.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/DomainObjectState.cs @@ -70,8 +70,6 @@ namespace Squidex.Domain.Apps.Entities clone.LastModified = headers.Timestamp(); clone.LastModifiedBy = payload.Actor; - clone.Version = headers.EventStreamNumber(); - return (clone as T)!; } } diff --git a/backend/src/Squidex.Infrastructure/Commands/Is.cs b/backend/src/Squidex.Infrastructure/Commands/Is.cs index ef36fdf11..a5abbcb2e 100644 --- a/backend/src/Squidex.Infrastructure/Commands/Is.cs +++ b/backend/src/Squidex.Infrastructure/Commands/Is.cs @@ -18,7 +18,7 @@ namespace Squidex.Infrastructure.Commands return !Equals(oldValue, newValue); } - public static bool Change(string oldValue, string newValue) + public static bool Change(string? oldValue, string? newValue) { return !Equals(oldValue, newValue); } diff --git a/backend/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs b/backend/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs index dfd04966e..66855d2c6 100644 --- a/backend/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs +++ b/backend/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs @@ -56,12 +56,12 @@ namespace Squidex.Infrastructure.Commands protected sealed override bool ApplyEvent(Envelope @event, bool isLoading) { - var newVersion = Version + 1; - var snapshot = OnEvent(@event); if (!ReferenceEquals(Snapshot, snapshot) || isLoading) { + var newVersion = Version + 1; + snapshot.Version = newVersion; snapshots.Add(snapshot); diff --git a/backend/src/Squidex/Config/Domain/StoreServices.cs b/backend/src/Squidex/Config/Domain/StoreServices.cs index 7d9cb8f4a..ba35d5714 100644 --- a/backend/src/Squidex/Config/Domain/StoreServices.cs +++ b/backend/src/Squidex/Config/Domain/StoreServices.cs @@ -81,6 +81,9 @@ namespace Squidex.Config.Domain services.AddTransientAs() .As(); + services.AddTransientAs() + .As(); + services.AddHealthChecks() .AddCheck("MongoDB", tags: new[] { "node" }); diff --git a/backend/tools/Migrate_01/MigrationPath.cs b/backend/tools/Migrate_01/MigrationPath.cs index 5bcf60f01..ac581c4c2 100644 --- a/backend/tools/Migrate_01/MigrationPath.cs +++ b/backend/tools/Migrate_01/MigrationPath.cs @@ -108,16 +108,24 @@ namespace Migrate_01 yield return serviceProvider.GetRequiredService(); } - // Version 17: Rename slug field. - if (version < 17) + // Version 18: Rebuild assets. + if (version < 18) { - yield return serviceProvider.GetService(); + yield return serviceProvider.GetService(); } - - // Version 20: Rebuild assets. - if (version < 20) + else { - yield return serviceProvider.GetService(); + // Version 17: Rename slug field. + if (version < 17) + { + yield return serviceProvider.GetService(); + } + + // Version 20: Rename slug field. + if (version < 20) + { + yield return serviceProvider.GetService(); + } } // Version 16: Introduce file name slugs for assets. diff --git a/backend/tools/Migrate_01/Migrations/MongoDb/RenameAssetMetadata.cs b/backend/tools/Migrate_01/Migrations/MongoDb/RenameAssetMetadata.cs new file mode 100644 index 000000000..d08e14ebf --- /dev/null +++ b/backend/tools/Migrate_01/Migrations/MongoDb/RenameAssetMetadata.cs @@ -0,0 +1,42 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using System.Threading.Tasks; +using MongoDB.Bson; +using MongoDB.Driver; +using Squidex.Infrastructure.Migrations; + +namespace Migrate_01.Migrations.MongoDb +{ + public sealed class RenameAssetMetadata : IMigration + { + private readonly IMongoDatabase database; + + public RenameAssetMetadata(IMongoDatabase database) + { + this.database = database; + } + + public async Task UpdateAsync() + { + var collection = database.GetCollection("States_Assets"); + + var update1 = + Builders.Update + .Set("md", new BsonDocument()); + + await collection.UpdateManyAsync(new BsonDocument(), update1); + + var update2 = + Builders.Update + .Rename("ph", "md.PixelHeight") + .Rename("pw", "md.PixelWidth"); + + await collection.UpdateManyAsync(new BsonDocument(), update2); + } + } +} diff --git a/frontend/app/features/administration/pages/restore/restore-page.component.html b/frontend/app/features/administration/pages/restore/restore-page.component.html index 76ce5f32b..3f6105e1b 100644 --- a/frontend/app/features/administration/pages/restore/restore-page.component.html +++ b/frontend/app/features/administration/pages/restore/restore-page.component.html @@ -54,7 +54,7 @@
- +
diff --git a/frontend/app/shared/state/backups.forms.ts b/frontend/app/shared/state/backups.forms.ts index 7c365e636..986486177 100644 --- a/frontend/app/shared/state/backups.forms.ts +++ b/frontend/app/shared/state/backups.forms.ts @@ -20,7 +20,7 @@ export class RestoreForm extends Form { constructor(formBuilder: FormBuilder) { super(formBuilder.group({ - newAppName: ['', + name: ['', [ Validators.maxLength(40), ValidatorsEx.pattern('[a-z0-9]+(\-[a-z0-9]+)*', 'Name can contain lower case letters (a-z), numbers and dashes (not at the end).')