diff --git a/src/Squidex.Domain.Apps.Entities/Schemas/Commands/CreateSchema.cs b/src/Squidex.Domain.Apps.Entities/Schemas/Commands/CreateSchema.cs index 923499e79..9c39fa5a9 100644 --- a/src/Squidex.Domain.Apps.Entities/Schemas/Commands/CreateSchema.cs +++ b/src/Squidex.Domain.Apps.Entities/Schemas/Commands/CreateSchema.cs @@ -22,6 +22,8 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Commands public SchemaProperties Properties { get; set; } + public bool Singleton { get; set; } + public bool Publish { get; set; } public CreateSchema() diff --git a/src/Squidex.Domain.Apps.Entities/Schemas/ISchemaEntity.cs b/src/Squidex.Domain.Apps.Entities/Schemas/ISchemaEntity.cs index 335a91e92..7f5ccf51e 100644 --- a/src/Squidex.Domain.Apps.Entities/Schemas/ISchemaEntity.cs +++ b/src/Squidex.Domain.Apps.Entities/Schemas/ISchemaEntity.cs @@ -25,6 +25,8 @@ namespace Squidex.Domain.Apps.Entities.Schemas bool IsPublished { get; } + bool IsSingleton { get; } + bool IsDeleted { get; } string ScriptQuery { get; } diff --git a/src/Squidex.Domain.Apps.Entities/Schemas/State/SchemaState.cs b/src/Squidex.Domain.Apps.Entities/Schemas/State/SchemaState.cs index 4a787d912..01bd7a7d1 100644 --- a/src/Squidex.Domain.Apps.Entities/Schemas/State/SchemaState.cs +++ b/src/Squidex.Domain.Apps.Entities/Schemas/State/SchemaState.cs @@ -37,6 +37,9 @@ namespace Squidex.Domain.Apps.Entities.Schemas.State [JsonProperty] public bool IsDeleted { get; set; } + [JsonProperty] + public bool IsSingleton { get; set; } + [JsonProperty] public string ScriptQuery { get; set; } @@ -65,6 +68,8 @@ namespace Squidex.Domain.Apps.Entities.Schemas.State { Name = @event.Name; + IsSingleton = @event.Singleton; + var schema = new Schema(@event.Name); if (@event.Properties != null) diff --git a/src/Squidex.Domain.Apps.Events/Schemas/SchemaCreated.cs b/src/Squidex.Domain.Apps.Events/Schemas/SchemaCreated.cs index 2e7c6ec2b..6f4f24295 100644 --- a/src/Squidex.Domain.Apps.Events/Schemas/SchemaCreated.cs +++ b/src/Squidex.Domain.Apps.Events/Schemas/SchemaCreated.cs @@ -20,6 +20,8 @@ namespace Squidex.Domain.Apps.Events.Schemas public SchemaProperties Properties { get; set; } + public bool Singleton { get; set; } + public bool Publish { get; set; } } } diff --git a/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaGrainTests.cs b/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaGrainTests.cs index bf0e83ad7..cd880f849 100644 --- a/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaGrainTests.cs +++ b/tests/Squidex.Domain.Apps.Entities.Tests/Schemas/SchemaGrainTests.cs @@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas { var properties = new SchemaProperties(); - var command = new CreateSchema { Name = SchemaName, SchemaId = SchemaId, Properties = properties }; + var command = new CreateSchema { Name = SchemaName, SchemaId = SchemaId, Properties = properties, Singleton = true }; var result = await sut.ExecuteAsync(CreateCommand(command)); @@ -72,10 +72,11 @@ namespace Squidex.Domain.Apps.Entities.Schemas Assert.Equal(SchemaName, sut.Snapshot.Name); Assert.Equal(SchemaName, sut.Snapshot.SchemaDef.Name); + Assert.True(sut.Snapshot.IsSingleton); LastEvents .ShouldHaveSameEvents( - CreateEvent(new SchemaCreated { Name = SchemaName, Properties = properties }) + CreateEvent(new SchemaCreated { Name = SchemaName, Properties = properties, Singleton = true }) ); }