Skip to content

Commit

Permalink
Fix MySQL index length
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Oct 17, 2023
1 parent 7f51a1c commit f6366f9
Show file tree
Hide file tree
Showing 19 changed files with 1,459 additions and 78 deletions.
1 change: 1 addition & 0 deletions src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="Localization\" />
<Folder Include="Recipes\" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/OrchardCore.Cms.Web/Recipes/.placeholder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file is used to ensure the Recipe folder is created

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public int Create()
);

// The index in MySQL can accommodate up to 768 characters or 3072 bytes.
// DocumentId (2) + ContentType (254) + ContentPart (254) + ContentField (254) + Published (1) + Latest (1) = 766 (less than 768)
// DocumentId (2) + ContentType (254) + ContentPart (254) + ContentField (254) + Published and Latest (1) = 765 (< 768).
SchemaBuilder.AlterIndexTable<UserPickerFieldIndex>(table => table
.CreateIndex("IDX_UserPickerFieldIndex_DocumentId_ContentType",
"DocumentId",
Expand Down Expand Up @@ -67,7 +67,7 @@ public int UpdateFrom1()
);

// The index in MySQL can accommodate up to 768 characters or 3072 bytes.
// DocumentId (2) + ContentType (254) + ContentPart (254) + ContentField (254) + Published (1) + Latest (1) = 766 (less than 768)
// DocumentId (2) + ContentType (254) + ContentPart (254) + ContentField (254) + Published and Latest (1) = 765 (< 768).
SchemaBuilder.AlterIndexTable<UserPickerFieldIndex>(table => table
.CreateIndex("IDX_UserPickerFieldIndex_DocumentId_ContentType",
"DocumentId",
Expand Down
8 changes: 4 additions & 4 deletions src/OrchardCore.Modules/OrchardCore.Indexing/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class Migrations : DataMigration
public int Create()
{
SchemaBuilder.CreateTable(nameof(IndexingTask), table => table
.Column<int>(nameof(IndexingTask.Id), col => col.PrimaryKey().Identity())
.Column<string>(nameof(IndexingTask.ContentItemId), c => c.WithLength(26))
.Column<DateTime>(nameof(IndexingTask.CreatedUtc), col => col.NotNull())
.Column<int>(nameof(IndexingTask.Type))
.Column<int>("Id", col => col.PrimaryKey().Identity())
.Column<string>("ContentItemId", c => c.WithLength(26))
.Column<DateTime>("CreatedUtc", col => col.NotNull())
.Column<int>("Type")
);

SchemaBuilder.AlterTable(nameof(IndexingTask), table => table
Expand Down
9 changes: 6 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Layers/Migrations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Threading.Tasks;
using OrchardCore.Data.Migration;
using OrchardCore.Layers.Indexes;
Expand Down Expand Up @@ -31,7 +30,9 @@ public int Create()
);

SchemaBuilder.AlterIndexTable<LayerMetadataIndex>(table => table
.CreateIndex("IDX_LayerMetadataIndex_DocumentId", "DocumentId", "Zone")
.CreateIndex("IDX_LayerMetadataIndex_DocumentId",
"DocumentId",
"Zone")
);

// Shortcut other migration steps on new content definition schemas.
Expand All @@ -42,7 +43,9 @@ public int Create()
public int UpdateFrom1()
{
SchemaBuilder.AlterIndexTable<LayerMetadataIndex>(table => table
.CreateIndex("IDX_LayerMetadataIndex_DocumentId", "DocumentId", "Zone")
.CreateIndex("IDX_LayerMetadataIndex_DocumentId",
"DocumentId",
"Zone")
);

return 2;
Expand Down
5 changes: 4 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Lists/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public int UpdateFrom1()
public int UpdateFrom2()
{
SchemaBuilder.AlterIndexTable<ContainedPartIndex>(table => table
.CreateIndex("IDX_ContainedPartIndex_DocumentId", "DocumentId", "ListContentItemId", "Order")
.CreateIndex("IDX_ContainedPartIndex_DocumentId",
"DocumentId",
"ListContentItemId",
"Order")
);

return 3;
Expand Down
16 changes: 10 additions & 6 deletions src/OrchardCore.Modules/OrchardCore.Taxonomies/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ public int Create()
"Latest")
);

// The index in MySQL can accommodate up to 768 characters or 3072 bytes.
// DocumentId (2) + ContentType (254) + ContentPart (254) + ContentField (254) + Published and Latest (1) = 765 (< 768).
SchemaBuilder.AlterIndexTable<TaxonomyIndex>(table => table
.CreateIndex("IDX_TaxonomyIndex_DocumentId_ContentType",
"DocumentId",
"ContentType",
"ContentPart",
"ContentField",
"ContentType(254)",
"ContentPart(254)",
"ContentField(254)",
"Published",
"Latest")
);
Expand Down Expand Up @@ -125,12 +127,14 @@ public int UpdateFrom3()
"Latest")
);

// The index in MySQL can accommodate up to 768 characters or 3072 bytes.
// DocumentId (2) + ContentType (254) + ContentPart (254) + ContentField (254) + Published and Latest (1) = 765 (< 768).
SchemaBuilder.AlterIndexTable<TaxonomyIndex>(table => table
.CreateIndex("IDX_TaxonomyIndex_DocumentId_ContentType",
"DocumentId",
"ContentType",
"ContentPart",
"ContentField",
"ContentType(254)",
"ContentPart(254)",
"ContentField(254)",
"Published",
"Latest")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public OpenIdMigrations(ISession session)
public int Create()
{
SchemaBuilder.CreateMapIndexTable<OpenIdApplicationIndex>(table => table
.Column<string>(nameof(OpenIdApplicationIndex.ApplicationId), column => column.WithLength(48))
.Column<string>(nameof(OpenIdApplicationIndex.ClientId), column => column.Unique()),
.Column<string>("ApplicationId", column => column.WithLength(48))
.Column<string>("ClientId", column => column.Unique()),
collection: OpenIdApplicationCollection);

SchemaBuilder.AlterIndexTable<OpenIdApplicationIndex>(table => table
Expand Down
Loading

0 comments on commit f6366f9

Please sign in to comment.