diff --git a/src/OrchardCore.Modules/OrchardCore.Alias/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Alias/Migrations.cs index c6848fbacce..649a18fb59a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Alias/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Alias/Migrations.cs @@ -24,10 +24,10 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(AliasPart), buil .WithDescription("Provides a way to define custom aliases for content items.")); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("Alias", col => col.WithLength(AliasPart.MaxAliasLength)) - .Column("ContentItemId", c => c.WithLength(26)) - .Column("Latest", c => c.WithDefault(false)) - .Column("Published", c => c.WithDefault(true)) + .Column("Alias", column => column.WithLength(AliasPart.MaxAliasLength)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("Latest", column => column.WithDefault(false)) + .Column("Published", column => column.WithDefault(true)) ); await SchemaBuilder.AlterIndexTableAsync(table => table @@ -47,11 +47,11 @@ await SchemaBuilder.AlterIndexTableAsync(table => table public async Task UpdateFrom1Async() { await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Latest", c => c.WithDefault(false)) + .AddColumn("Latest", column => column.WithDefault(false)) ); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Published", c => c.WithDefault(true)) + .AddColumn("Published", column => column.WithDefault(true)) ); return 2; diff --git a/src/OrchardCore.Modules/OrchardCore.ArchiveLater/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.ArchiveLater/Migrations.cs index f62335d3a4c..4770fe4650a 100644 --- a/src/OrchardCore.Modules/OrchardCore.ArchiveLater/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.ArchiveLater/Migrations.cs @@ -25,7 +25,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(ArchiveLaterPart .WithDescription("Adds the ability to schedule content items to be archived at a given future date and time.")); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId") + .Column("ContentItemId", column => column.NotNull().WithLength(26)) .Column("ScheduledArchiveDateTimeUtc") .Column("Published") .Column("Latest") diff --git a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Migrations.cs index ab5423ac5fb..1cd8bcff8f5 100644 --- a/src/OrchardCore.Modules/OrchardCore.AuditTrail/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.AuditTrail/Migrations.cs @@ -12,11 +12,11 @@ public class Migrations : DataMigration public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column(nameof(AuditTrailEventIndex.EventId), column => column.WithLength(26)) + .Column(nameof(AuditTrailEventIndex.EventId), column => column.NotNull().WithLength(26)) .Column(nameof(AuditTrailEventIndex.Category), column => column.WithLength(64)) .Column(nameof(AuditTrailEventIndex.Name), column => column.WithLength(64)) - .Column(nameof(AuditTrailEventIndex.CorrelationId), column => column.WithLength(26)) - .Column(nameof(AuditTrailEventIndex.UserId), column => column.WithLength(26)) + .Column(nameof(AuditTrailEventIndex.CorrelationId), column => column.NotNull().WithLength(26)) + .Column(nameof(AuditTrailEventIndex.UserId), column => column.NotNull().WithLength(26)) .Column(nameof(AuditTrailEventIndex.NormalizedUserName), column => column.Nullable().WithLength(255)) .Column(nameof(AuditTrailEventIndex.CreatedUtc), column => column.Nullable()), collection: AuditTrailEvent.Collection); diff --git a/src/OrchardCore.Modules/OrchardCore.Autoroute/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Autoroute/Migrations.cs index 7db23059adf..d4355ecc34a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Autoroute/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Autoroute/Migrations.cs @@ -24,10 +24,10 @@ await _contentDefinitionManager.AlterPartDefinitionAsync("AutoroutePart", builde .WithDescription("Provides a custom url for your content item.")); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", c => c.WithLength(26)) - .Column("ContainedContentItemId", c => c.WithLength(26)) - .Column("JsonPath", c => c.Unlimited()) - .Column("Path", col => col.WithLength(AutoroutePart.MaxPathLength)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContainedContentItemId", column => column.WithLength(26)) // Cannot be non-null + .Column("JsonPath", column => column.Unlimited()) + .Column("Path", column => column.WithLength(AutoroutePart.MaxPathLength)) .Column("Published") .Column("Latest") ); @@ -57,15 +57,15 @@ public int UpdateFrom2() public async Task UpdateFrom3Async() { await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("ContainedContentItemId", c => c.WithLength(26)) + .AddColumn("ContainedContentItemId", column => column.WithLength(26)) ); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("JsonPath", c => c.Unlimited()) + .AddColumn("JsonPath", column => column.Unlimited()) ); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Latest", c => c.WithDefault(false)) + .AddColumn("Latest", column => column.WithDefault(false)) ); return 4; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/Migrations.cs index 19ae0d9a242..8cc8b3f5ebe 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/Migrations.cs @@ -24,8 +24,8 @@ public async Task CreateAsync() // For existing SQL databases update the TextFieldIndex tables Text column length manually. // INFO: The Text Length is now of 766 chars, but this is only used on a new installation. await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -67,8 +67,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -100,8 +100,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -140,8 +140,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -180,8 +180,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -221,8 +221,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -261,8 +261,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -305,8 +305,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table // The BigText and BigUrl columns are new additions so will not be populated until the content item is republished. // INFO: The Url and Text Length is now of 766 chars, but this is only used on a new installation. await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -361,8 +361,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -393,8 +393,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) @@ -455,8 +455,8 @@ await SchemaBuilder.AlterIndexTableAsync(table => table public async Task UpdateFrom2Async() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/UserPickerMigrations.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/UserPickerMigrations.cs index 06fd0dac97d..ef64cb20098 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/UserPickerMigrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Indexing/SQL/UserPickerMigrations.cs @@ -12,8 +12,8 @@ public class UserPickerMigrations : DataMigration public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ContentItemVersionId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Migrations.cs index 0e1e20217fe..a2b1926982d 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Migrations.cs @@ -27,9 +27,9 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(LocalizationPart .WithDescription("Provides a way to create localized version of content.")); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("LocalizationSet", col => col.WithLength(26)) - .Column("Culture", col => col.WithLength(16)) - .Column("ContentItemId", c => c.WithLength(26)) + .Column("LocalizationSet", column => column.NotNull().WithLength(26)) + .Column("Culture", column => column.NotNull().WithLength(16)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) .Column("Published") .Column("Latest") ); diff --git a/src/OrchardCore.Modules/OrchardCore.Indexing/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Indexing/Migrations.cs index daa2af05675..4de39310ff0 100644 --- a/src/OrchardCore.Modules/OrchardCore.Indexing/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Indexing/Migrations.cs @@ -9,9 +9,9 @@ public class Migrations : DataMigration public async Task CreateAsync() { await SchemaBuilder.CreateTableAsync(nameof(IndexingTask), table => table - .Column("Id", col => col.PrimaryKey().Identity()) - .Column("ContentItemId", c => c.WithLength(26)) - .Column("CreatedUtc", col => col.NotNull()) + .Column("Id", column => column.PrimaryKey().Identity()) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("CreatedUtc", column => column.NotNull()) .Column("Type") ); diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs index 5a8339d0399..666d3495212 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs @@ -27,7 +27,7 @@ public Migrations( public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("Zone", c => c.WithLength(64)) + .Column("Zone", column => column.WithLength(64)) ); await SchemaBuilder.AlterIndexTableAsync(table => table diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Migrations.cs index 038c58aec7c..96ebcba7d6f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Migrations.cs @@ -24,8 +24,8 @@ await _contentDefinitionManager.AlterPartDefinitionAsync("ListPart", builder => .WithDescription("Add a list behavior.")); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", column => column.WithLength(26)) - .Column("ListContentItemId", column => column.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ListContentItemId", column => column.NotNull().WithLength(26)) .Column("DisplayText") .Column("Order") .Column("ListContentType") diff --git a/src/OrchardCore.Modules/OrchardCore.Notifications/Migrations/NotificationMigrations.cs b/src/OrchardCore.Modules/OrchardCore.Notifications/Migrations/NotificationMigrations.cs index f8015b28709..54a5e470054 100644 --- a/src/OrchardCore.Modules/OrchardCore.Notifications/Migrations/NotificationMigrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Notifications/Migrations/NotificationMigrations.cs @@ -11,7 +11,7 @@ public class NotificationMigrations : DataMigration public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("NotificationId", column => column.WithLength(26)) + .Column("NotificationId", column => column.NotNull().WithLength(26)) .Column("UserId", column => column.WithLength(26)) .Column("IsRead") .Column("ReadAtUtc") diff --git a/src/OrchardCore.Modules/OrchardCore.PublishLater/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.PublishLater/Migrations.cs index f227c53faa6..bd99340377b 100644 --- a/src/OrchardCore.Modules/OrchardCore.PublishLater/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.PublishLater/Migrations.cs @@ -24,7 +24,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync("PublishLaterPart", bui .WithDescription("Adds the ability to schedule content items to be published at a given future date and time.")); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId") + .Column("ContentItemId", column => column.NotNull().WithLength(26)) .Column("ScheduledPublishDateTimeUtc") .Column("Published") .Column("Latest") diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Migrations.cs index 16f3858f608..34b6e798c9f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Migrations.cs @@ -44,14 +44,14 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync("Taxonomy", taxonomy => ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("TaxonomyContentItemId", c => c.WithLength(26)) - .Column("ContentItemId", c => c.WithLength(26)) + .Column("TaxonomyContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) .Column("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize)) .Column("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize)) - .Column("TermContentItemId", column => column.WithLength(26)) - .Column("Published", c => c.WithDefault(true)) - .Column("Latest", c => c.WithDefault(false)) + .Column("TermContentItemId", column => column.NotNull().WithLength(26)) + .Column("Published", column => column.WithDefault(true)) + .Column("Latest", column => column.WithDefault(false)) ); await SchemaBuilder.AlterIndexTableAsync(table => table @@ -110,11 +110,11 @@ public async Task UpdateFrom3Async() { // This step has been updated to also add these new columns. await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Published", c => c.WithDefault(true)) + .AddColumn("Published", column => column.WithDefault(true)) ); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Latest", c => c.WithDefault(false)) + .AddColumn("Latest", column => column.WithDefault(false)) ); // So that the new indexes can be fully created. @@ -150,11 +150,11 @@ public async Task UpdateFrom4Async() // This step run only if the previous one was executed before // it was updated, so here we also add the following columns. await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Published", c => c.WithDefault(true)) + .AddColumn("Published", column => column.WithDefault(true)) ); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("Latest", c => c.WithDefault(false)) + .AddColumn("Latest", column => column.WithDefault(false)) ); // But we create a separate index for these new columns. diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Users/Migrations.cs index 6e8f182a55f..e0a33c1d783 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Migrations.cs @@ -20,11 +20,11 @@ public async Task CreateAsync() await SchemaBuilder.CreateMapIndexTableAsync(table => table .Column("NormalizedUserName") // TODO These should have defaults. on SQL Server they will fall at 255. Exceptions are currently thrown if you go over that. .Column("NormalizedEmail") - .Column("IsEnabled", c => c.NotNull().WithDefault(true)) - .Column("IsLockoutEnabled", c => c.NotNull().WithDefault(false)) - .Column("LockoutEndUtc", c => c.Nullable()) - .Column("AccessFailedCount", c => c.NotNull().WithDefault(0)) - .Column("UserId") + .Column("IsEnabled", column => column.NotNull().WithDefault(true)) + .Column("IsLockoutEnabled", column => column.NotNull().WithDefault(false)) + .Column("LockoutEndUtc", column => column.Nullable()) + .Column("AccessFailedCount", column => column.NotNull().WithDefault(0)) + .Column("UserId", column => column.NotNull()) ); await SchemaBuilder.AlterIndexTableAsync(table => table @@ -108,7 +108,7 @@ await SchemaBuilder.CreateMapIndexTableAsync(table => table public async Task UpdateFrom3Async() { await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("IsEnabled", c => c.NotNull().WithDefault(true))); + .AddColumn("IsEnabled", column => column.NotNull().WithDefault(true))); return 4; } @@ -220,13 +220,13 @@ await SchemaBuilder.AlterIndexTableAsync(table => table public async Task UpdateFrom10Async() { await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("IsLockoutEnabled", c => c.NotNull().WithDefault(false))); + .AddColumn("IsLockoutEnabled", column => column.NotNull().WithDefault(false))); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("LockoutEndUtc", c => c.Nullable())); + .AddColumn("LockoutEndUtc", column => column.Nullable())); await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("AccessFailedCount", c => c.NotNull().WithDefault(0))); + .AddColumn("AccessFailedCount", column => column.NotNull().WithDefault(0))); return 11; } diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Migrations.cs index 78a9a89bbde..a15ab762d54 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Migrations.cs @@ -11,7 +11,7 @@ public class Migrations : DataMigration public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("WorkflowTypeId", c => c.WithLength(26)) + .Column("WorkflowTypeId", column => column.NotNull().WithLength(26)) .Column("Name") .Column("IsEnabled") .Column("HasStart") @@ -27,10 +27,10 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("WorkflowTypeId") + .Column("WorkflowTypeId", column => column.NotNull().WithLength(26)) .Column("Name") .Column("IsEnabled") - .Column("StartActivityId") + .Column("StartActivityId", column => column.NotNull().WithLength(26)) .Column("StartActivityName") ); @@ -44,9 +44,9 @@ await SchemaBuilder.AlterIndexTableAsync(table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("WorkflowTypeId", c => c.WithLength(26)) - .Column("WorkflowId", c => c.WithLength(26)) - .Column("WorkflowStatus", c => c.WithLength(26)) + .Column("WorkflowTypeId", column => column.WithLength(26)) + .Column("WorkflowId", column => column.WithLength(26)) + .Column("WorkflowStatus", column => column.WithLength(26)) .Column("CreatedUtc") ); @@ -60,12 +60,12 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ActivityId") + .Column("ActivityId", column => column.NotNull().WithLength(26)) .Column("ActivityName") .Column("ActivityIsStart") - .Column("WorkflowTypeId") - .Column("WorkflowId") - .Column("WorkflowCorrelationId") + .Column("WorkflowTypeId", column => column.NotNull().WithLength(26)) + .Column("WorkflowId", column => column.NotNull().WithLength(26)) + .Column("WorkflowCorrelationId", column => column.NotNull().WithLength(26)) ); await SchemaBuilder.AlterIndexTableAsync(table => table diff --git a/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs b/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs index cb1bd57ac49..15dd35a76d0 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs @@ -71,6 +71,8 @@ public async Task NewAsync(string contentType) var context2 = new ActivatedContentContext(context.ContentItem); context2.ContentItem.ContentItemId = _idGenerator.GenerateUniqueId(context2.ContentItem); + context2.ContentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(context2.ContentItem); + context2.ContentItem.Latest = true; await ReversedHandlers.InvokeAsync((handler, context2) => handler.ActivatedAsync(context2), context2, _logger); @@ -599,19 +601,20 @@ protected async Task> BuildNewVersionsAsync(IEnumerable public async Task CreateAsync(ContentItem contentItem, VersionOptions options) { - if (string.IsNullOrEmpty(contentItem.ContentItemVersionId)) - { - contentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(contentItem); - contentItem.Published = true; - contentItem.Latest = true; - } + contentItem.Published = true; // Draft flag on create is required for explicitly-published content items if (options.IsDraft) { + contentItem.Latest = true; contentItem.Published = false; } + if (string.IsNullOrEmpty(contentItem.ContentItemVersionId)) + { + contentItem.ContentItemVersionId = _idGenerator.GenerateUniqueId(contentItem); + } + // Build a context with the initialized instance to create var context = new CreateContentContext(contentItem); diff --git a/src/OrchardCore/OrchardCore.ContentManagement/Records/Migrations.cs b/src/OrchardCore/OrchardCore.ContentManagement/Records/Migrations.cs index 456db5f02e5..2c65ea1248c 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement/Records/Migrations.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement/Records/Migrations.cs @@ -20,8 +20,8 @@ public Migrations(IContentDefinitionManager contentDefinitionManager) public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", c => c.WithLength(26)) - .Column("ContentItemVersionId", c => c.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) // Cannot be not null .Column("Latest") .Column("Published") .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize)) @@ -84,7 +84,7 @@ await SchemaBuilder.AlterIndexTableAsync(table => table public async Task UpdateFrom1Async() { await SchemaBuilder.AlterIndexTableAsync(table => table - .AddColumn("ContentItemVersionId", c => c.WithLength(26)) + .AddColumn("ContentItemVersionId", column => column.WithLength(26)) ); return 2; diff --git a/src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs b/src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs index e3c87fcebb6..281507f4a2e 100644 --- a/src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs +++ b/src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Migrations/OpenIdMigrations.cs @@ -25,7 +25,7 @@ public OpenIdMigrations(ISession session) public async Task CreateAsync() { await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ApplicationId", column => column.WithLength(48)) + .Column("ApplicationId", column => column.NotNull().WithLength(48)) .Column("ClientId", column => column.Unique()), collection: OpenIdApplicationCollection); @@ -68,7 +68,7 @@ await SchemaBuilder.AlterIndexTableAsync(table => tabl ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("AuthorizationId", column => column.WithLength(48)) + .Column("AuthorizationId", column => column.NotNull().WithLength(48)) .Column("ApplicationId", column => column.WithLength(48)) .Column("Status") .Column("Subject") @@ -97,7 +97,7 @@ await SchemaBuilder.AlterIndexTableAsync(table => tabl await SchemaBuilder.CreateMapIndexTableAsync(table => table .Column("Name", column => column.Unique()) - .Column("ScopeId", column => column.WithLength(48)), + .Column("ScopeId", column => column.NotNull().WithLength(48)), collection: OpenIdScopeCollection); await SchemaBuilder.AlterIndexTableAsync(table => table @@ -120,7 +120,7 @@ await SchemaBuilder.AlterIndexTableAsync(table => ta ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("TokenId", column => column.WithLength(48)) + .Column("TokenId", column => column.NotNull().WithLength(48)) .Column("ApplicationId", column => column.WithLength(48)) .Column("AuthorizationId", column => column.WithLength(48)) .Column("ExpirationDate") @@ -299,7 +299,7 @@ public async Task UpdateFrom6Async() { // Create all index tables with the new collection value. await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("TokenId", column => column.WithLength(48)) + .Column("TokenId", column => column.NotNull().WithLength(48)) .Column("ApplicationId", column => column.WithLength(48)) .Column("AuthorizationId", column => column.WithLength(48)) .Column("ExpirationDate") @@ -339,7 +339,7 @@ await SchemaBuilder.AlterIndexTableAsync(table => table ); await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("AuthorizationId", column => column.WithLength(48)) + .Column("AuthorizationId", column => column.NotNull().WithLength(48)) .Column("ApplicationId", column => column.WithLength(48)) .Column("Status") .Column("Subject") @@ -404,7 +404,7 @@ public async Task UpdateFrom7Async() { // Create all index tables with the new collection value. await SchemaBuilder.CreateMapIndexTableAsync(table => table - .Column("ApplicationId", column => column.WithLength(48)) + .Column("ApplicationId", column => column.NotNull().WithLength(48)) .Column("ClientId", column => column.Unique()), collection: OpenIdApplicationCollection); diff --git a/test/OrchardCore.Tests/Apis/GraphQL/ContentItemsFieldTypeTests.cs b/test/OrchardCore.Tests/Apis/GraphQL/ContentItemsFieldTypeTests.cs index e64eb6713da..e8cd5e5219c 100644 --- a/test/OrchardCore.Tests/Apis/GraphQL/ContentItemsFieldTypeTests.cs +++ b/test/OrchardCore.Tests/Apis/GraphQL/ContentItemsFieldTypeTests.cs @@ -104,8 +104,8 @@ private static async Task CreateTablesAsync(IStore store) var builder = new SchemaBuilder(store.Configuration, await session.BeginTransactionAsync()); await builder.CreateMapIndexTableAsync(table => table - .Column("ContentItemId", c => c.WithLength(26)) - .Column("ContentItemVersionId", c => c.WithLength(26)) + .Column("ContentItemId", column => column.NotNull().WithLength(26)) + .Column("ContentItemVersionId", column => column.NotNull().WithLength(26)) .Column("Latest") .Column("Published") .Column("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))