diff --git a/CLAUDE.md b/CLAUDE.md index b8928da15..8389f4363 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -44,6 +44,9 @@ Some tests need test setup or test containers which are slow. Run the tests like dotnet test --filter "Category!=Dependencies & Category!=TestContainer" ``` +- Use xUnit assertions (`Assert.Equal`, `Assert.True`, `Assert.Single`, `Assert.Empty`, ...) for simple properties and values. +- Use FluentAssertions (`Should().BeEquivalentTo(...)`) only for deep, structural comparisons of objects and collections. + ### Best Practices - Code style is enforced by StyleCop (`backend/stylecop.json`) and `.editorconfig` — follow the surrounding file's conventions. diff --git a/backend/i18n/frontend_de.json b/backend/i18n/frontend_de.json index bf0cd2f87..702555ffc 100644 --- a/backend/i18n/frontend_de.json +++ b/backend/i18n/frontend_de.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Fehler beim Laden der Schemas. Bitte neu laden.", "schemas.loadSchemaFailed": "Fehler beim Laden des Schemas. Bitte neu laden.", "schemas.lockFieldFailed": "Fehler beim Sperren des Feldes. Bitte neu laden.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Komponente", "schemas.modeComponentDescription": "Kann nur in Komponentenfelder eingebettet werden...", "schemas.modeMultiple": "Mehrere Inhalte", diff --git a/backend/i18n/frontend_en.json b/backend/i18n/frontend_en.json index b54c5cae2..51430ac0d 100644 --- a/backend/i18n/frontend_en.json +++ b/backend/i18n/frontend_en.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Failed to load schemas. Please reload.", "schemas.loadSchemaFailed": "Failed to load schema. Please reload.", "schemas.lockFieldFailed": "Failed to lock field. Please reload.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Component", "schemas.modeComponentDescription": "Can only be embedded to component fields...", "schemas.modeMultiple": "Multiple contents", diff --git a/backend/i18n/frontend_fr.json b/backend/i18n/frontend_fr.json index b68c18df3..848f8a27e 100644 --- a/backend/i18n/frontend_fr.json +++ b/backend/i18n/frontend_fr.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Échec du chargement des schémas. Veuillez recharger.", "schemas.loadSchemaFailed": "Échec du chargement du schéma. Veuillez recharger.", "schemas.lockFieldFailed": "Impossible de verrouiller le champ. Veuillez recharger.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Composant", "schemas.modeComponentDescription": "Ne peut être intégré qu'aux champs de composant...", "schemas.modeMultiple": "Contenus multiples", diff --git a/backend/i18n/frontend_it.json b/backend/i18n/frontend_it.json index fd42379f9..41d1db349 100644 --- a/backend/i18n/frontend_it.json +++ b/backend/i18n/frontend_it.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Non è stato possibile caricare gli schemi. Per favore ricarica.", "schemas.loadSchemaFailed": "Non è stato possibile caricare lo schema. Per favore ricarica.", "schemas.lockFieldFailed": "Non è stato possibile bloccare il campo. Per favore ricarica.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Component", "schemas.modeComponentDescription": "Can only be embedded to component fields...", "schemas.modeMultiple": "Contenuti multipli", diff --git a/backend/i18n/frontend_nl.json b/backend/i18n/frontend_nl.json index c4e5d68e2..b2c46cc1a 100644 --- a/backend/i18n/frontend_nl.json +++ b/backend/i18n/frontend_nl.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Kan schema's niet laden. Laad opnieuw.", "schemas.loadSchemaFailed": "Kan schema niet laden. Laad opnieuw.", "schemas.lockFieldFailed": "Kan veld niet vergrendelen. Laad opnieuw.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Component", "schemas.modeComponentDescription": "Kan alleen worden gebruikt in componentvelden...", "schemas.modeMultiple": "Meerdere inhoud", diff --git a/backend/i18n/frontend_pt.json b/backend/i18n/frontend_pt.json index c388e190a..ceaf0aa26 100644 --- a/backend/i18n/frontend_pt.json +++ b/backend/i18n/frontend_pt.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Falhou em carregar esquemas. Por favor, recarregue.", "schemas.loadSchemaFailed": "Falhou em carregar o esquema. Por favor, recarregue.", "schemas.lockFieldFailed": "Falhou em bloquear o campo. Por favor, recarregue.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Componente", "schemas.modeComponentDescription": "Só pode ser incorporado em campos componentes...", "schemas.modeMultiple": "Vários conteúdos", diff --git a/backend/i18n/frontend_zh.json b/backend/i18n/frontend_zh.json index 9c92da7e7..3557d52f6 100644 --- a/backend/i18n/frontend_zh.json +++ b/backend/i18n/frontend_zh.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "加载Schemas失败。请重新加载。", "schemas.loadSchemaFailed": "Failed to load schema. Please reload.", "schemas.lockFieldFailed": "无法锁定字段。请重新加载。", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Component", "schemas.modeComponentDescription": "只能嵌入到组件字段...", "schemas.modeMultiple": "多个内容", diff --git a/backend/i18n/source/frontend_en.json b/backend/i18n/source/frontend_en.json index b54c5cae2..51430ac0d 100644 --- a/backend/i18n/source/frontend_en.json +++ b/backend/i18n/source/frontend_en.json @@ -1033,6 +1033,13 @@ "schemas.loadFailed": "Failed to load schemas. Please reload.", "schemas.loadSchemaFailed": "Failed to load schema. Please reload.", "schemas.lockFieldFailed": "Failed to lock field. Please reload.", + "schemas.migrateContents": "Migrate Contents", + "schemas.migrateContentsButton": "Start Migration", + "schemas.migrateContentsConfirmText": "Do you really want to migrate all contents of this schema? This can take a while and creates a new version for every changed content.", + "schemas.migrateContentsConfirmTitle": "Migrate Contents", + "schemas.migrateContentsFailed": "Failed to start the content migration.", + "schemas.migrateContentsHint": "Schema changes are not applied to the stored contents. The API removes invalid values from the responses, but queries and indexes still run over the raw data and can fail. Start a migration to rewrite all contents of this schema so that the stored data matches the current schema. The migration runs as a **job** and its progress is shown on the jobs page.", + "schemas.migrateContentsStarted": "Content migration started, it can take several minutes to complete.", "schemas.modeComponent": "Component", "schemas.modeComponentDescription": "Can only be embedded to component fields...", "schemas.modeMultiple": "Multiple contents", diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Migration/MigrateContentsJob.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Migration/MigrateContentsJob.cs new file mode 100644 index 000000000..f392a3648 --- /dev/null +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Migration/MigrateContentsJob.cs @@ -0,0 +1,202 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using Squidex.Domain.Apps.Core.Apps; +using Squidex.Domain.Apps.Core.ConvertContent; +using Squidex.Domain.Apps.Core.Schemas; +using Squidex.Domain.Apps.Entities.Contents.Commands; +using Squidex.Domain.Apps.Entities.Contents.Repositories; +using Squidex.Domain.Apps.Entities.Jobs; +using Squidex.Infrastructure; +using Squidex.Infrastructure.Commands; +using Squidex.Infrastructure.Json; +using Squidex.Infrastructure.States; +using Squidex.Infrastructure.Tasks; + +namespace Squidex.Domain.Apps.Entities.Contents.Migration; + +public sealed class MigrateContentsJob( + IAppProvider appProvider, + ICommandBus commandBus, + IContentRepository contentRepository, + IContextProvider contextProvider, + IJsonSerializer jsonSerializer) + : IJobRunner +{ + public const string TaskName = "migrateContents"; + public const string ArgAppId = "appId"; + public const string ArgAppName = "appName"; + public const string ArgSchemaId = "schemaId"; + public const string ArgSchemaName = "schemaName"; + + // Schema changes are not applied to the stored contents, therefore a lot of items can be affected. + private const int BatchSize = 100; + + public string Name => TaskName; + + public static JobRequest BuildRequest(RefToken actor, App app, Schema schema) + { + Guard.NotNull(actor); + Guard.NotNull(app); + Guard.NotNull(schema); + + return JobRequest.Create( + actor, + TaskName, + new Dictionary + { + [ArgAppId] = app.Id.ToString(), + [ArgAppName] = app.Name, + [ArgSchemaId] = schema.Id.ToString(), + [ArgSchemaName] = schema.Name, + }) with + { + AppId = app.NamedId(), + }; + } + + public async Task RunAsync(JobRunContext context, + CancellationToken ct) + { + // The other arguments are just there for debugging purposes. Therefore do not validate them. + if (!context.Job.Arguments.TryGetValue(ArgSchemaId, out var schemaIdValue)) + { + throw new DomainException($"Argument '{ArgSchemaId}' missing."); + } + + if (!context.Job.Arguments.TryGetValue(ArgSchemaName, out var schemaName)) + { + throw new DomainException($"Argument '{ArgSchemaName}' missing."); + } + + var schemaId = DomainId.Create(schemaIdValue); + + var (app, schema) = await appProvider.GetAppWithSchemaAsync(context.OwnerId, schemaId, ct: ct); + if (app == null) + { + throw new DomainObjectNotFoundException(context.OwnerId.ToString()); + } + + if (schema == null) + { + throw new DomainObjectNotFoundException(schemaIdValue); + } + + // Use a readable name to describe the job. + context.Job.Description = $"Schema {schemaName}: Migrate contents"; + + // The job is not running in the scope of a request, therefore we have to provide the context for the commands. + contextProvider.Context = Context.Admin(app).Clone(b => b + .WithNoEnrichment() + .WithNoCleanup() + .WithUnpublished(true)); + + var components = await appProvider.GetComponentsAsync(schema, ct); + var converter = BuildConverter(app, schema, components); + + // Buffer the batches, so that the next contents are read while the current batch is written. + var batches = + contentRepository.StreamAll(app.Id, [schemaId], SearchScope.All, ct) + .Batch(BatchSize, ct) + .Buffered(2, ct); + + var totalCount = 0; + var totalUpdates = 0; + + // The progress is a single log line, but it must not overwrite the errors of the previous batch. + var replaceProgress = false; + + await foreach (var batch in batches) + { + var jobs = new List(batch.Count); + + foreach (var content in batch) + { + // The converter takes ownership of the data, therefore the clone is needed for the comparison. + var converted = converter.Convert(content.Data.Clone()); + if (converted.Equals(content.Data)) + { + continue; + } + + jobs.Add(new BulkUpdateJob + { + Id = content.Id, + Data = converted, + Type = BulkUpdateContentType.Update, + }); + } + + totalCount += batch.Count; + totalUpdates += jobs.Count; + + var errors = 0; + + if (jobs.Count > 0) + { + errors = await UpdateAsync(context, app, schema, jobs, ct); + } + + await context.LogAsync($"Checked contents: {totalCount}, updated: {totalUpdates}", replaceProgress && errors == 0); + replaceProgress = true; + } + + await context.LogAsync($"Checked contents: {totalCount}, updated: {totalUpdates}", replaceProgress); + } + + private ContentConverter BuildConverter(App app, Schema schema, ResolvedComponents components) + { + // The converter itself removes all fields and components that are not part of the schema anymore. + var converter = new ContentConverter(components, schema); + + // Remove all values that are not compatible with the current field type. + converter.Add(new ExcludeChangedTypes(jsonSerializer)); + + // Move the values over when the partitioning of a field has been changed. + converter.Add(new ResolveFromPreviousPartitioning(app.Languages)); + + return converter; + } + + private async Task UpdateAsync(JobRunContext context, App app, Schema schema, List jobs, + CancellationToken ct) + { + // The contents are only converted to the current schema, therefore all custom logic must be skipped. + var command = new BulkUpdateContents + { + Jobs = jobs.ToArray(), + Actor = context.Actor, + AppId = app.NamedId(), + DoNotScript = true, + DoNotValidate = true, + DoNotValidateWorkflow = true, + OptimizeValidation = true, + SchemaId = schema.NamedId(), + }; + + var commandContext = await commandBus.PublishAsync(command, ct); + + // Errors are reported per content item, so that a single invalid item does not stop the migration. + if (commandContext.PlainResult is not BulkUpdateResult result) + { + return 0; + } + + var errors = 0; + + foreach (var item in result) + { + if (item.Exception != null) + { + await context.LogAsync($"Failed to migrate content {item.Id}: {item.Exception.Message}"); + errors++; + } + } + + return errors; + } +} diff --git a/backend/src/Squidex.Shared/PermissionIds.cs b/backend/src/Squidex.Shared/PermissionIds.cs index 26e246c13..49b57cbe8 100644 --- a/backend/src/Squidex.Shared/PermissionIds.cs +++ b/backend/src/Squidex.Shared/PermissionIds.cs @@ -206,6 +206,7 @@ public static class PermissionIds public const string AppSchemasPublish = "squidex.apps.{app}.schemas.{schema}.publish"; public const string AppSchemasDelete = "squidex.apps.{app}.schemas.{schema}.delete"; public const string AppSchemasIndexes = "squidex.apps.{app}.schemas.{schema}.indexes"; + public const string AppSchemasMigrate = "squidex.apps.{app}.schemas.{schema}.migrate"; // App Contents public const string AppContents = "squidex.apps.{app}.contents.{schema}"; diff --git a/backend/src/Squidex.Web/Resources.cs b/backend/src/Squidex.Web/Resources.cs index 76f50e228..9534808ec 100644 --- a/backend/src/Squidex.Web/Resources.cs +++ b/backend/src/Squidex.Web/Resources.cs @@ -46,6 +46,8 @@ public sealed class Resources(ApiController controller) public bool CanManageIndexes(string schema) => Can(PermissionIds.AppSchemasIndexes, schema); + public bool CanMigrateSchemaContents(string schema) => Can(PermissionIds.AppSchemasMigrate, schema); + public bool CanCreateSchema => Can(PermissionIds.AppSchemasCreate); public bool CanUpdateSettings => Can(PermissionIds.AppUpdateSettings); diff --git a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs index 5a4520d5e..72d5e625d 100644 --- a/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs +++ b/backend/src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaDto.cs @@ -174,6 +174,12 @@ public class SchemaDto : Resource resources.Url(x => nameof(x.PostContent), values) + "?publish=true"); } + if (resources.CanMigrateSchemaContents(Name) && Type != SchemaType.Component) + { + AddPostLink("contents/migrate", + resources.Url(x => nameof(x.PostContentMigration), values)); + } + if (resources.CanPublishSchema(Name)) { if (IsPublished) diff --git a/backend/src/Squidex/Areas/Api/Controllers/Schemas/SchemaContentsController.cs b/backend/src/Squidex/Areas/Api/Controllers/Schemas/SchemaContentsController.cs new file mode 100644 index 000000000..b13ed030b --- /dev/null +++ b/backend/src/Squidex/Areas/Api/Controllers/Schemas/SchemaContentsController.cs @@ -0,0 +1,49 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using Microsoft.AspNetCore.Mvc; +using Squidex.Domain.Apps.Entities.Contents.Migration; +using Squidex.Domain.Apps.Entities.Jobs; +using Squidex.Infrastructure.Commands; +using Squidex.Infrastructure.Security; +using Squidex.Shared; +using Squidex.Web; + +namespace Squidex.Areas.Api.Controllers.Schemas; + +/// +/// Update and query information about schemas. +/// +[ApiExplorerSettings(GroupName = nameof(Schemas))] +[ApiModelValidation(true)] +public class SchemaContentsController(ICommandBus commandBus, IJobService jobService) : ApiController(commandBus) +{ + /// + /// Migrate the contents to the current schema. + /// + /// The name of the app. + /// The name of the schema. + /// Content migration added to job queue. + /// Schema or app not found. + /// + /// Schema changes are not applied to the stored contents. This endpoint starts a job that rewrites all + /// contents of the schema so that the stored data matches the current schema. + /// + [HttpPost] + [Route("apps/{app}/schemas/{schema}/contents/migrate")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ApiPermissionOrAnonymous(PermissionIds.AppSchemasMigrate)] + [ApiCosts(1)] + public async Task PostContentMigration(string app, string schema) + { + var job = MigrateContentsJob.BuildRequest(User.Token()!, App, Schema); + + await jobService.StartAsync(App.Id, job, HttpContext.RequestAborted); + + return NoContent(); + } +} diff --git a/backend/src/Squidex/Config/Messaging/MessagingServices.cs b/backend/src/Squidex/Config/Messaging/MessagingServices.cs index 8297a7856..2a5a07ffa 100644 --- a/backend/src/Squidex/Config/Messaging/MessagingServices.cs +++ b/backend/src/Squidex/Config/Messaging/MessagingServices.cs @@ -14,6 +14,7 @@ using Squidex.Domain.Apps.Entities.Backup; using Squidex.Domain.Apps.Entities.Billing; using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents.Indexes; +using Squidex.Domain.Apps.Entities.Contents.Migration; using Squidex.Domain.Apps.Entities.Jobs; using Squidex.Domain.Apps.Entities.Rules.Runner; using Squidex.Domain.Apps.Entities.Rules.UsageTracking; @@ -96,6 +97,9 @@ public static class MessagingServices services.AddSingletonAs() .As(); + services.AddSingletonAs() + .As(); + services.AddSingleton(c => new SystemTextJsonMessagingSerializer(c.GetRequiredService())); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Migration/MigrateContentsJobTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Migration/MigrateContentsJobTests.cs new file mode 100644 index 000000000..bda2fb440 --- /dev/null +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Migration/MigrateContentsJobTests.cs @@ -0,0 +1,255 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using Squidex.Domain.Apps.Core; +using Squidex.Domain.Apps.Core.Contents; +using Squidex.Domain.Apps.Core.Schemas; +using Squidex.Domain.Apps.Entities.Contents.Commands; +using Squidex.Domain.Apps.Entities.Contents.Repositories; +using Squidex.Domain.Apps.Entities.Jobs; +using Squidex.Domain.Apps.Entities.TestHelpers; +using Squidex.Infrastructure; +using Squidex.Infrastructure.Collections; +using Squidex.Infrastructure.Commands; +using Squidex.Infrastructure.States; +using IClock = NodaTime.IClock; +using TestUtils = Squidex.Domain.Apps.Core.TestHelpers.TestUtils; + +namespace Squidex.Domain.Apps.Entities.Contents.Migration; + +public class MigrateContentsJobTests : GivenContext +{ + private readonly ICommandBus commandBus = A.Fake(); + private readonly IContentRepository contentRepository = A.Fake(); + private readonly IContextProvider contextProvider = A.Fake(); + private readonly List commands = []; + private readonly MigrateContentsJob sut; + private BulkUpdateResult bulkUpdateResult = new BulkUpdateResult(); + + public MigrateContentsJobTests() + { + Schema = + Schema + .AddNumber(1, "my-field", Partitioning.Invariant) + .AddString(2, "my-string", Partitioning.Invariant); + + A.CallTo(() => commandBus.PublishAsync(A._, A._)) + .ReturnsLazily(x => + { + var command = x.GetArgument(0)!; + + if (command is BulkUpdateContents bulkUpdate) + { + commands.Add(bulkUpdate); + } + + return Task.FromResult(new CommandContext(command, commandBus).Complete(bulkUpdateResult)); + }); + + sut = new MigrateContentsJob(AppProvider, commandBus, contentRepository, contextProvider, TestUtils.DefaultSerializer); + } + + [Fact] + public void Should_create_request() + { + var job = MigrateContentsJob.BuildRequest(User, App, Schema); + + job.Arguments.Should().BeEquivalentTo( + new Dictionary + { + ["appId"] = App.Id.ToString(), + ["appName"] = App.Name, + ["schemaId"] = Schema.Id.ToString(), + ["schemaName"] = Schema.Name, + }); + } + + [Fact] + public async Task Should_throw_exception_if_arguments_do_not_contain_schemaId() + { + var context = CreateRunContext(new Job + { + Arguments = new Dictionary + { + ["schemaName"] = Schema.Name, + }.ToReadonlyDictionary(), + }); + + await Assert.ThrowsAsync(() => sut.RunAsync(context, CancellationToken)); + } + + [Fact] + public async Task Should_throw_exception_if_arguments_do_not_contain_schemaName() + { + var context = CreateRunContext(new Job + { + Arguments = new Dictionary + { + ["schemaId"] = Schema.Id.ToString(), + }.ToReadonlyDictionary(), + }); + + await Assert.ThrowsAsync(() => sut.RunAsync(context, CancellationToken)); + } + + [Fact] + public async Task Should_throw_exception_if_schema_not_found() + { + A.CallTo(() => AppProvider.GetAppWithSchemaAsync(AppId.Id, SchemaId.Id, A._, A._)) + .Returns((App, null as Schema)); + + var context = CreateRunContext(CreateJob()); + + await Assert.ThrowsAsync(() => sut.RunAsync(context, CancellationToken)); + } + + [Fact] + public async Task Should_not_update_content_if_data_matches_schema() + { + SetupContents(CreateContent(new ContentData() + .AddField("my-field", + new ContentFieldData() + .AddInvariant(42)) + .AddField("my-string", + new ContentFieldData() + .AddInvariant("hello")))); + + await sut.RunAsync(CreateRunContext(CreateJob()), CancellationToken); + + Assert.Empty(commands); + } + + [Fact] + public async Task Should_update_content_with_invalid_values() + { + var content = CreateContent(new ContentData() + .AddField("my-field", + new ContentFieldData() + .AddInvariant("invalid")) + .AddField("my-string", + new ContentFieldData() + .AddInvariant("hello")) + .AddField("removed-field", + new ContentFieldData() + .AddInvariant(42))); + + SetupContents(content); + + await sut.RunAsync(CreateRunContext(CreateJob()), CancellationToken); + + var command = Assert.Single(commands); + + Assert.Equal(SchemaId, command.SchemaId); + Assert.True(command.DoNotScript); + Assert.True(command.DoNotValidate); + Assert.True(command.DoNotValidateWorkflow); + + var job = Assert.Single(command.Jobs!); + + Assert.Equal(content.Id, job.Id); + Assert.Equal(BulkUpdateContentType.Update, job.Type); + + // The invalid value and the field that is not part of the schema anymore are removed. + job.Data.Should().BeEquivalentTo( + new ContentData() + .AddField("my-string", + new ContentFieldData() + .AddInvariant("hello"))); + } + + [Fact] + public async Task Should_update_contents_in_batches() + { + var contents = Enumerable.Range(0, 150).Select(_ => CreateContent(new ContentData() + .AddField("my-field", + new ContentFieldData() + .AddInvariant("invalid")))).ToArray(); + + SetupContents(contents); + + await sut.RunAsync(CreateRunContext(CreateJob()), CancellationToken); + + Assert.Equal([100, 50], commands.Select(x => x.Jobs!.Length)); + } + + [Fact] + public async Task Should_log_progress_as_single_line() + { + var contents = Enumerable.Range(0, 150).Select(_ => CreateContent(new ContentData() + .AddField("my-field", + new ContentFieldData() + .AddInvariant("invalid")))).ToArray(); + + SetupContents(contents); + + var context = CreateRunContext(CreateJob()); + + await sut.RunAsync(context, CancellationToken); + + Assert.Equal("Checked contents: 150, updated: 150", Assert.Single(context.Job.Log).Message); + } + + [Fact] + public async Task Should_not_overwrite_errors_with_progress() + { + var content = CreateContent(new ContentData() + .AddField("my-field", + new ContentFieldData() + .AddInvariant("invalid"))); + + SetupContents(content); + + bulkUpdateResult = new BulkUpdateResult([new BulkUpdateResultItem(content.Id, 0, new DomainException("Error"))]); + + var context = CreateRunContext(CreateJob()); + + await sut.RunAsync(context, CancellationToken); + + Assert.Equal( + [ + $"Failed to migrate content {content.Id}: Error", + "Checked contents: 1, updated: 1", + ], + context.Job.Log.Select(x => x.Message)); + } + + private void SetupContents(params Content[] contents) + { + A.CallTo(() => contentRepository.StreamAll(AppId.Id, A>._, SearchScope.All, A._)) + .Returns(contents.ToAsyncEnumerable()); + } + + private Content CreateContent(ContentData data) + { + var content = CreateContent(); + + content.Data = data; + + return content; + } + + private Job CreateJob() + { + return new Job + { + Arguments = new Dictionary + { + ["appId"] = App.Id.ToString(), + ["appName"] = App.Name, + ["schemaId"] = Schema.Id.ToString(), + ["schemaName"] = Schema.Name, + }.ToReadonlyDictionary(), + }; + } + + private JobRunContext CreateRunContext(Job job) + { + var state = new SimpleState(A.Fake>(), GetType(), App.Id); + + return new JobRunContext(state, A.Fake(), default) { Actor = User, Job = job, OwnerId = App.Id }; + } +} diff --git a/frontend/generator/Generator.sln b/frontend/generator/Generator.sln deleted file mode 100644 index 9b3263c02..000000000 --- a/frontend/generator/Generator.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.12.35707.178 d17.12 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{0BD7AC0B-640B-4D26-A9B9-C1CCEE4C14E7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0BD7AC0B-640B-4D26-A9B9-C1CCEE4C14E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0BD7AC0B-640B-4D26-A9B9-C1CCEE4C14E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0BD7AC0B-640B-4D26-A9B9-C1CCEE4C14E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0BD7AC0B-640B-4D26-A9B9-C1CCEE4C14E7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/frontend/generator/Generator.slnx b/frontend/generator/Generator.slnx new file mode 100644 index 000000000..59a326e59 --- /dev/null +++ b/frontend/generator/Generator.slnx @@ -0,0 +1,3 @@ + + + diff --git a/frontend/generator/Generator/cache.json b/frontend/generator/Generator/cache.json index 998dec50c..148ba2bf8 100644 --- a/frontend/generator/Generator/cache.json +++ b/frontend/generator/Generator/cache.json @@ -1,5 +1,5 @@ { - "x-generator": "NSwag v14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))", + "x-generator": "NSwag v14.7.1.0 (NJsonSchema v11.6.1.0 (Newtonsoft.Json v13.0.0.0))", "openapi": "3.0.0", "info": { "title": "Squidex API", @@ -332,7 +332,7 @@ "security": [ { "squidex-oauth-auth": [ - "squidex.admin.users.unlock" + "squidex.admin.users.delete" ] } ] @@ -2088,6 +2088,73 @@ ] } }, + "/api/apps/{app}/schemas/{schema}/contents/migrate": { + "post": { + "tags": [ + "Schemas" + ], + "summary": "Migrate the contents to the current schema.", + "description": "Schema changes are not applied to the stored contents. This endpoint starts a job that rewrites all\ncontents of the schema so that the stored data matches the current schema.", + "operationId": "SchemaContents_PostContentMigration", + "parameters": [ + { + "name": "app", + "in": "path", + "required": true, + "description": "The name of the app.", + "schema": { + "type": "string" + }, + "x-position": 1 + }, + { + "name": "schema", + "in": "path", + "required": true, + "description": "The name of the schema.", + "schema": { + "type": "string" + }, + "x-position": 2 + } + ], + "responses": { + "204": { + "description": "Content migration added to job queue." + }, + "404": { + "description": "Schema or app not found." + }, + "400": { + "description": "Validation error.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorDto" + } + } + } + }, + "500": { + "description": "Operation failed.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorDto" + } + } + } + } + }, + "security": [ + { + "squidex-oauth-auth": [ + "squidex.apps.{app}.schemas.{schema}.migrate" + ] + } + ] + } + }, "/api/apps/{app}/schemas/{schema}/fields": { "post": { "tags": [ diff --git a/frontend/src/app/features/schemas/pages/schema/common/schema-migrate-form.component.html b/frontend/src/app/features/schemas/pages/schema/common/schema-migrate-form.component.html new file mode 100644 index 000000000..11500e15c --- /dev/null +++ b/frontend/src/app/features/schemas/pages/schema/common/schema-migrate-form.component.html @@ -0,0 +1,20 @@ +
{{ "schemas.migrateContents" | sqxTranslate }}
+ +
+
+ +
+ + +
diff --git a/frontend/src/app/features/schemas/pages/schema/common/schema-migrate-form.component.ts b/frontend/src/app/features/schemas/pages/schema/common/schema-migrate-form.component.ts new file mode 100644 index 000000000..32ee8b49c --- /dev/null +++ b/frontend/src/app/features/schemas/pages/schema/common/schema-migrate-form.component.ts @@ -0,0 +1,37 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + + +import { Component, Input } from '@angular/core'; +import { ConfirmClickDirective, MarkdownDirective, SchemaDto, SchemasState, TranslatePipe } from '@app/shared'; + +@Component({ + selector: 'sqx-schema-migrate-form', + templateUrl: './schema-migrate-form.component.html', + imports: [ + ConfirmClickDirective, + MarkdownDirective, + TranslatePipe, + ], +}) +export class SchemaMigrateFormComponent { + @Input({ required: true }) + public schema!: SchemaDto; + + constructor( + private readonly schemasState: SchemasState, + ) { + } + + public migrateContents() { + if (!this.schema.canContentsMigrate) { + return; + } + + this.schemasState.migrateContents(this.schema).subscribe(); + } +} diff --git a/frontend/src/app/features/schemas/pages/schema/schema-page.component.html b/frontend/src/app/features/schemas/pages/schema/schema-page.component.html index a88d31877..f648be5a4 100644 --- a/frontend/src/app/features/schemas/pages/schema/schema-page.component.html +++ b/frontend/src/app/features/schemas/pages/schema/schema-page.component.html @@ -120,6 +120,9 @@ } + @if (schema.type !== "Component") { + + } } diff --git a/frontend/src/app/features/schemas/pages/schema/schema-page.component.ts b/frontend/src/app/features/schemas/pages/schema/schema-page.component.ts index 344e620ba..90d3b1a24 100644 --- a/frontend/src/app/features/schemas/pages/schema/schema-page.component.ts +++ b/frontend/src/app/features/schemas/pages/schema/schema-page.component.ts @@ -12,6 +12,7 @@ import { map } from 'rxjs/operators'; import { ConfirmClickDirective, defined, DropdownMenuComponent, LanguagesState, LayoutComponent, ListViewComponent, MessageBus, ModalDirective, ModalModel, ModalPlacementDirective, SchemaDto, SchemasState, SidebarMenuDirective, Subscriptions, TitleComponent, TooltipDirective, TourStepDirective, TranslatePipe, UIOptions } from '@app/shared'; import { SchemaCloning } from '../messages'; import { SchemaEditFormComponent } from './common/schema-edit-form.component'; +import { SchemaMigrateFormComponent } from './common/schema-migrate-form.component'; import { SchemaExportFormComponent } from './export/schema-export-form.component'; import { SchemaFieldsComponent } from './fields/schema-fields.component'; import { SchemaIndexesComponent } from './indexes/schema-indexes.component'; @@ -40,6 +41,7 @@ import { SchemaUIFormComponent } from './ui/schema-ui-form.component'; SchemaFieldRulesFormComponent, SchemaFieldsComponent, SchemaIndexesComponent, + SchemaMigrateFormComponent, SchemaPreviewUrlsFormComponent, SchemaScriptsFormComponent, SchemaUIFormComponent, diff --git a/frontend/src/app/shared/model/custom.ts b/frontend/src/app/shared/model/custom.ts index b18a62d48..f584caacd 100644 --- a/frontend/src/app/shared/model/custom.ts +++ b/frontend/src/app/shared/model/custom.ts @@ -486,6 +486,10 @@ export class SchemaDto extends generated.SchemaDto { return this.compute('canContentsCreateAndPublish', () => hasAnyLink(this._links, 'contents/create/publish')); } + public get canContentsMigrate() { + return this.compute('canContentsMigrate', () => hasAnyLink(this._links, 'contents/migrate')); + } + public get canContentsRead() { return this.compute('canContentsRead', () => hasAnyLink(this._links, 'contents')); } diff --git a/frontend/src/app/shared/model/generated.ts b/frontend/src/app/shared/model/generated.ts index 9d9060e65..3350f43ca 100644 --- a/frontend/src/app/shared/model/generated.ts +++ b/frontend/src/app/shared/model/generated.ts @@ -2283,6 +2283,10 @@ export class SchemaDto extends ResourceDto implements ISchemaDto { return this.compute('canContentsCreateAndPublish', () => hasAnyLink(this._links, 'contents/create/publish')); } + public get canContentsMigrate() { + return this.compute('canContentsMigrate', () => hasAnyLink(this._links, 'contents/migrate')); + } + public get canContentsRead() { return this.compute('canContentsRead', () => hasAnyLink(this._links, 'contents')); } diff --git a/frontend/src/app/shared/services/schemas.service.spec.ts b/frontend/src/app/shared/services/schemas.service.spec.ts index e2a36e730..9fbf05529 100644 --- a/frontend/src/app/shared/services/schemas.service.spec.ts +++ b/frontend/src/app/shared/services/schemas.service.spec.ts @@ -541,6 +541,23 @@ describe('SchemasService', () => { expect(schema!).toEqual(createSchema(12)); })); + it('should make post request to migrate contents', inject([SchemasService, HttpTestingController], (schemasService: SchemasService, httpMock: HttpTestingController) => { + const resource: Resource = { + _links: { + 'contents/migrate': { method: 'POST', href: '/api/apps/my-app/schemas/my-schema/contents/migrate' }, + }, + }; + + schemasService.postContentMigration('my-app', resource).subscribe(); + + const req = httpMock.expectOne('http://service/p/api/apps/my-app/schemas/my-schema/contents/migrate'); + + expect(req.request.method).toEqual('POST'); + expect(req.request.headers.get('If-Match')).toBeNull(); + + req.flush({}); + })); + it('should make delete request to delete schema', inject([SchemasService, HttpTestingController], (schemasService: SchemasService, httpMock: HttpTestingController) => { const resource: Resource = { _links: { diff --git a/frontend/src/app/shared/services/schemas.service.ts b/frontend/src/app/shared/services/schemas.service.ts index efab6b2c4..74c327be3 100644 --- a/frontend/src/app/shared/services/schemas.service.ts +++ b/frontend/src/app/shared/services/schemas.service.ts @@ -279,6 +279,15 @@ export class SchemasService { pretifyError('i18n:schemas.deleteFieldFailed')); } + public postContentMigration(appName: string, resource: Resource): Observable { + const link = resource._links['contents/migrate']; + + const url = this.apiUrl.buildUrl(link.href); + + return this.http.request(link.method, url).pipe( + pretifyError('i18n:schemas.migrateContentsFailed')); + } + public deleteSchema(appName: string, resource: Resource, version: VersionOrTag): Observable> { const link = resource._links['delete']; diff --git a/frontend/src/app/shared/state/schemas.state.spec.ts b/frontend/src/app/shared/state/schemas.state.spec.ts index 23d19b6ad..2709a0cab 100644 --- a/frontend/src/app/shared/state/schemas.state.spec.ts +++ b/frontend/src/app/shared/state/schemas.state.spec.ts @@ -189,6 +189,24 @@ describe('SchemasState', () => { expect(schemasState.snapshot.schemas).toEqualIgnoringProps([updated, schema2]); }); + it('should notify if content migration has been started', () => { + schemasService.setup(x => x.postContentMigration(app, schema1)) + .returns(() => of({})).verifiable(); + + schemasState.migrateContents(schema1).subscribe(); + + dialogs.verify(x => x.notifyInfo(It.isAnyString()), Times.once()); + }); + + it('should not change schemas if content migration has been started', () => { + schemasService.setup(x => x.postContentMigration(app, schema1)) + .returns(() => of({})).verifiable(); + + schemasState.migrateContents(schema1).subscribe(); + + expect(schemasState.snapshot.schemas).toEqualIgnoringProps([schema1, schema2]); + }); + describe('with selection', () => { beforeEach(() => { schemasService.setup(x => x.getSchema(app, schema1.name)) diff --git a/frontend/src/app/shared/state/schemas.state.ts b/frontend/src/app/shared/state/schemas.state.ts index 1cf9d2dfe..17be7c96f 100644 --- a/frontend/src/app/shared/state/schemas.state.ts +++ b/frontend/src/app/shared/state/schemas.state.ts @@ -175,6 +175,14 @@ export class SchemasState extends State { shareSubscribed(this.dialogs)); } + public migrateContents(schema: SchemaDto): Observable { + return this.schemasService.postContentMigration(this.appName, schema).pipe( + tap(() => { + this.dialogs.notifyInfo('i18n:schemas.migrateContentsStarted'); + }), + shareSubscribed(this.dialogs)); + } + public addCategory(name: string) { this.next(s => { const categories = new Set([...s.addedCategories, name]); diff --git a/tools/TestSuite/TestSuite.ApiTests/ContentMigrationTests.cs b/tools/TestSuite/TestSuite.ApiTests/ContentMigrationTests.cs new file mode 100644 index 000000000..dc7f31161 --- /dev/null +++ b/tools/TestSuite/TestSuite.ApiTests/ContentMigrationTests.cs @@ -0,0 +1,100 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using Squidex.ClientLibrary; +using TestSuite.Fixtures; +using TestSuite.Model; + +#pragma warning disable SA1300 // Element should begin with upper-case letter +#pragma warning disable SA1507 // Code should not contain multiple blank lines in a row + +namespace TestSuite.ApiTests; + +public class ContentMigrationTests(ClientFixture fixture) : IClassFixture +{ + private readonly string appName = Guid.NewGuid().ToString(); + private readonly string schemaName = $"schema-{Guid.NewGuid()}"; + + public ClientFixture _ { get; } = fixture; + + [Fact] + public async Task Should_migrate_contents_with_invalid_values() + { + // STEP 0: Create app, because jobs cannot run in parallel within the same app. + var (app, _) = await _.PostAppAsync(appName); + + + // STEP 1: Create a schema. + var schema = await TestEntity.CreateSchemaAsync(app.Schemas, schemaName); + + var contents = app.Contents(schemaName); + + + // STEP 2: Create a content that becomes invalid and a content that stays valid. + var contentInvalid_1 = await contents.CreateAsync( + new TestEntityData + { + String = "hello", + }, + ContentCreateOptions.AsPublish); + + var contentValid_1 = await contents.CreateAsync( + new TestEntityData + { + Number = 42, + }, + ContentCreateOptions.AsPublish); + + + // STEP 3: Change the type of the field, so that the stored value is not valid anymore. + await app.Schemas.DeleteFieldAsync(schemaName, schema.Fields.First(x => x.Name == TestEntityData.StringField).FieldId); + + await app.Schemas.PostFieldAsync(schemaName, new AddFieldDto + { + Name = TestEntityData.StringField, + Properties = new NumberFieldPropertiesDto + { + IsRequired = false, + }, + }); + + + // STEP 4: Start the migration. + await app.Schemas.PostContentMigrationAsync(schemaName); + + + // STEP 5: Wait for the migration to complete. + var job = await app.Jobs.PollAsync(x => x.TaskName == "migrateContents" && x.Status is JobStatus.Completed or JobStatus.Failed); + + Assert.Equal(JobStatus.Completed, job?.Status); + Assert.Equal("Checked contents: 2, updated: 1", Assert.Single(job!.Log).Message); + + + // STEP 6: Only the invalid content has been updated. + var contentInvalid_2 = await contents.GetAsync(contentInvalid_1.Id); + var contentValid_2 = await contents.GetAsync(contentValid_1.Id); + + Assert.Equal(contentInvalid_1.Version + 1, contentInvalid_2.Version); + Assert.Equal(contentValid_1.Version, contentValid_2.Version); + } + + [Fact] + public async Task Should_not_start_migration_for_unknown_schema() + { + // STEP 0: Create app. + var (app, _) = await _.PostAppAsync(appName); + + + // STEP 1: Start the migration. + var ex = await Assert.ThrowsAnyAsync(() => + { + return app.Schemas.PostContentMigrationAsync(schemaName); + }); + + Assert.Equal(404, ex.StatusCode); + } +} diff --git a/tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app_from_templates.verified.txt b/tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app_from_templates.verified.txt index ff76546aa..4bf4d1809 100644 --- a/tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app_from_templates.verified.txt +++ b/tools/TestSuite/TestSuite.ApiTests/Verify/AppCreationTests.Should_create_app_from_templates.verified.txt @@ -152,6 +152,9 @@ contents/create/publish: { Method: POST }, + contents/migrate: { + Method: POST + }, delete: { Method: DELETE }, @@ -345,6 +348,9 @@ contents/create/publish: { Method: POST }, + contents/migrate: { + Method: POST + }, delete: { Method: DELETE }, diff --git a/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema.verified.txt b/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema.verified.txt index bbc5ce19e..298b8d4fd 100644 --- a/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema.verified.txt +++ b/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema.verified.txt @@ -10,6 +10,9 @@ contents: { Method: GET }, + contents/migrate: { + Method: POST + }, delete: { Method: DELETE }, diff --git a/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt b/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt index bbc5ce19e..298b8d4fd 100644 --- a/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt +++ b/tools/TestSuite/TestSuite.ApiTests/Verify/SchemaTests.Should_create_singleton_schema_with_obsolete_property.verified.txt @@ -10,6 +10,9 @@ contents: { Method: GET }, + contents/migrate: { + Method: POST + }, delete: { Method: DELETE }, diff --git a/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj b/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj index ab8793629..d6f4056e6 100644 --- a/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj +++ b/tools/TestSuite/TestSuite.Shared/TestSuite.Shared.csproj @@ -18,8 +18,8 @@ - - + +