Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Id's not null #15131

Closed
wants to merge 13 commits into from
12 changes: 6 additions & 6 deletions src/OrchardCore.Modules/OrchardCore.Alias/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(AliasPart), buil
.WithDescription("Provides a way to define custom aliases for content items."));

await SchemaBuilder.CreateMapIndexTableAsync<AliasPartIndex>(table => table
.Column<string>("Alias", col => col.WithLength(AliasPart.MaxAliasLength))
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<bool>("Latest", c => c.WithDefault(false))
.Column<bool>("Published", c => c.WithDefault(true))
.Column<string>("Alias", column => column.WithLength(AliasPart.MaxAliasLength))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
Piedone marked this conversation as resolved.
Show resolved Hide resolved
.Column<bool>("Latest", column => column.WithDefault(false))
.Column<bool>("Published", column => column.WithDefault(true))
);

await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
Expand All @@ -47,11 +47,11 @@ await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
public async Task<int> UpdateFrom1Async()
{
await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
.AddColumn<bool>("Latest", c => c.WithDefault(false))
.AddColumn<bool>("Latest", column => column.WithDefault(false))
);

await SchemaBuilder.AlterIndexTableAsync<AliasPartIndex>(table => table
.AddColumn<bool>("Published", c => c.WithDefault(true))
.AddColumn<bool>("Published", column => column.WithDefault(true))
);

return 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArchiveLaterPartIndex>(table => table
.Column<string>("ContentItemId")
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<DateTime>("ScheduledArchiveDateTimeUtc")
.Column<bool>("Published")
.Column<bool>("Latest")
Expand Down
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.AuditTrail/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class Migrations : DataMigration
public async Task<int> CreateAsync()
{
await SchemaBuilder.CreateMapIndexTableAsync<AuditTrailEventIndex>(table => table
.Column<string>(nameof(AuditTrailEventIndex.EventId), column => column.WithLength(26))
.Column<string>(nameof(AuditTrailEventIndex.EventId), column => column.NotNull().WithLength(26))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates for all of these changes in this PR are also needed.

.Column<string>(nameof(AuditTrailEventIndex.Category), column => column.WithLength(64))
.Column<string>(nameof(AuditTrailEventIndex.Name), column => column.WithLength(64))
.Column<string>(nameof(AuditTrailEventIndex.CorrelationId), column => column.WithLength(26))
.Column<string>(nameof(AuditTrailEventIndex.UserId), column => column.WithLength(26))
.Column<string>(nameof(AuditTrailEventIndex.CorrelationId), column => column.NotNull().WithLength(26))
.Column<string>(nameof(AuditTrailEventIndex.UserId), column => column.NotNull().WithLength(26))
.Column<string>(nameof(AuditTrailEventIndex.NormalizedUserName), column => column.Nullable().WithLength(255))
.Column<DateTime>(nameof(AuditTrailEventIndex.CreatedUtc), column => column.Nullable()),
collection: AuditTrailEvent.Collection);
Expand Down
14 changes: 7 additions & 7 deletions src/OrchardCore.Modules/OrchardCore.Autoroute/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ await _contentDefinitionManager.AlterPartDefinitionAsync("AutoroutePart", builde
.WithDescription("Provides a custom url for your content item."));

await SchemaBuilder.CreateMapIndexTableAsync<AutoroutePartIndex>(table => table
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<string>("ContainedContentItemId", c => c.WithLength(26))
.Column<string>("JsonPath", c => c.Unlimited())
.Column<string>("Path", col => col.WithLength(AutoroutePart.MaxPathLength))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContainedContentItemId", column => column.WithLength(26)) // Cannot be non-null
.Column<string>("JsonPath", column => column.Unlimited())
.Column<string>("Path", column => column.WithLength(AutoroutePart.MaxPathLength))
.Column<bool>("Published")
.Column<bool>("Latest")
);
Expand Down Expand Up @@ -57,15 +57,15 @@ public int UpdateFrom2()
public async Task<int> UpdateFrom3Async()
{
await SchemaBuilder.AlterIndexTableAsync<AutoroutePartIndex>(table => table
.AddColumn<string>("ContainedContentItemId", c => c.WithLength(26))
.AddColumn<string>("ContainedContentItemId", column => column.WithLength(26))
);

await SchemaBuilder.AlterIndexTableAsync<AutoroutePartIndex>(table => table
.AddColumn<string>("JsonPath", c => c.Unlimited())
.AddColumn<string>("JsonPath", column => column.Unlimited())
);

await SchemaBuilder.AlterIndexTableAsync<AutoroutePartIndex>(table => table
.AddColumn<bool>("Latest", c => c.WithDefault(false))
.AddColumn<bool>("Latest", column => column.WithDefault(false))
);

return 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public async Task<int> 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<TextFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -66,8 +66,8 @@ await SchemaBuilder.AlterIndexTableAsync<TextFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<BooleanFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -99,8 +99,8 @@ await SchemaBuilder.AlterIndexTableAsync<BooleanFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<NumericFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -139,8 +139,8 @@ await SchemaBuilder.AlterIndexTableAsync<NumericFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<DateTimeFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -179,8 +179,8 @@ await SchemaBuilder.AlterIndexTableAsync<DateTimeFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<DateFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -220,8 +220,8 @@ await SchemaBuilder.AlterIndexTableAsync<DateFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<ContentPickerFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -260,8 +260,8 @@ await SchemaBuilder.AlterIndexTableAsync<ContentPickerFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<TimeFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -304,8 +304,8 @@ await SchemaBuilder.AlterIndexTableAsync<TimeFieldIndex>(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<LinkFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -360,8 +360,8 @@ await SchemaBuilder.AlterIndexTableAsync<LinkFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<HtmlFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -392,8 +392,8 @@ await SchemaBuilder.AlterIndexTableAsync<HtmlFieldIndex>(table => table
);

await SchemaBuilder.CreateMapIndexTableAsync<MultiTextFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down Expand Up @@ -454,8 +454,8 @@ await SchemaBuilder.AlterIndexTableAsync<LinkFieldIndex>(table => table
public async Task<int> UpdateFrom2Async()
{
await SchemaBuilder.CreateMapIndexTableAsync<MultiTextFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class UserPickerMigrations : DataMigration
public async Task<int> CreateAsync()
{
await SchemaBuilder.CreateMapIndexTableAsync<UserPickerFieldIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemVersionId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ContentItemVersionId", column => column.NotNull().WithLength(26))
.Column<string>("ContentType", column => column.WithLength(ContentItemIndex.MaxContentTypeSize))
.Column<string>("ContentPart", column => column.WithLength(ContentItemIndex.MaxContentPartSize))
.Column<string>("ContentField", column => column.WithLength(ContentItemIndex.MaxContentFieldSize))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(LocalizationPart
.WithDescription("Provides a way to create localized version of content."));

await SchemaBuilder.CreateMapIndexTableAsync<LocalizedContentItemIndex>(table => table
.Column<string>("LocalizationSet", col => col.WithLength(26))
.Column<string>("Culture", col => col.WithLength(16))
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<string>("LocalizationSet", column => column.NotNull().WithLength(26))
.Column<string>("Culture", column => column.NotNull().WithLength(16))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<bool>("Published")
.Column<bool>("Latest")
);
Expand Down
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Indexing/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public class Migrations : DataMigration
public async Task<int> CreateAsync()
{
await SchemaBuilder.CreateTableAsync(nameof(IndexingTask), table => table
.Column<int>("Id", col => col.PrimaryKey().Identity())
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<DateTime>("CreatedUtc", col => col.NotNull())
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<DateTime>("CreatedUtc", column => column.NotNull())
.Column<int>("Type")
);

Expand Down
2 changes: 1 addition & 1 deletion src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Migrations(
public async Task<int> CreateAsync()
{
await SchemaBuilder.CreateMapIndexTableAsync<LayerMetadataIndex>(table => table
.Column<string>("Zone", c => c.WithLength(64))
.Column<string>("Zone", column => column.WithLength(64))
);

await SchemaBuilder.AlterIndexTableAsync<LayerMetadataIndex>(table => table
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore.Modules/OrchardCore.Lists/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ await _contentDefinitionManager.AlterPartDefinitionAsync("ListPart", builder =>
.WithDescription("Add a list behavior."));

await SchemaBuilder.CreateMapIndexTableAsync<ContainedPartIndex>(table => table
.Column<string>("ContentItemId", column => column.WithLength(26))
.Column<string>("ListContentItemId", column => column.WithLength(26))
.Column<string>("ContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("ListContentItemId", column => column.NotNull().WithLength(26))
.Column<string>("DisplayText")
.Column<int>("Order")
.Column<string>("ListContentType")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class NotificationMigrations : DataMigration
public async Task<int> CreateAsync()
{
await SchemaBuilder.CreateMapIndexTableAsync<NotificationIndex>(table => table
.Column<string>("NotificationId", column => column.WithLength(26))
.Column<string>("NotificationId", column => column.NotNull().WithLength(26))
.Column<string>("UserId", column => column.WithLength(26))
.Column<bool>("IsRead")
.Column<DateTime>("ReadAtUtc")
Expand Down
Loading
Loading