Skip to content

Commit

Permalink
Projections: Consolidating Migration Update steps into Create
Browse files Browse the repository at this point in the history
  • Loading branch information
BenedekFarkas committed Mar 1, 2024
1 parent 35f1c8d commit 50d416c
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public int Create() {
.Column<int>("Id", c => c.PrimaryKey().Identity())
.Column<string>("PropertyName")
.Column<string>("Value", c => c.WithLength(4000))
.Column<string>("LatestValue", c => c.WithLength(4000))
.Column<int>("FieldIndexPartRecord_Id")
);

Expand All @@ -44,6 +45,7 @@ public int Create() {
.Column<int>("Id", c => c.PrimaryKey().Identity())
.Column<string>("PropertyName")
.Column<long>("Value")
.Column<long>("LatestValue")
.Column<int>("FieldIndexPartRecord_Id")
);

Expand All @@ -52,6 +54,7 @@ public int Create() {
.Column<int>("Id", c => c.PrimaryKey().Identity())
.Column<string>("PropertyName")
.Column<double>("Value")
.Column<double>("LatestValue")
.Column<int>("FieldIndexPartRecord_Id")
);

Expand All @@ -60,11 +63,25 @@ public int Create() {
.Column<int>("Id", c => c.PrimaryKey().Identity())
.Column<string>("PropertyName")
.Column<decimal>("Value")
.Column<decimal>("LatestValue")
.Column<int>("FieldIndexPartRecord_Id")
);

SchemaBuilder.CreateTable("FieldIndexPartRecord", table => table.ContentPartRecord());

//Adds indexes for better performances in queries
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("StringFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));

SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("IntegerFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));

SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("DoubleFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));

SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_PropertyName", new string[] { "PropertyName" }));
SchemaBuilder.AlterTable("DecimalFieldIndexRecord", table => table.CreateIndex("IX_FieldIndexPartRecord_Id", new string[] { "FieldIndexPartRecord_Id" }));

// Query

ContentDefinitionManager.AlterTypeDefinition("Query",
Expand All @@ -77,6 +94,7 @@ public int Create() {
SchemaBuilder.CreateTable("QueryPartRecord",
table => table
.ContentPartRecord()
.Column<string>("VersionScope", c => c.WithLength(15))
);

SchemaBuilder.CreateTable("FilterGroupRecord",
Expand Down Expand Up @@ -118,6 +136,7 @@ public int Create() {
.Column<int>("Display")
.Column<int>("QueryPartRecord_id")
.Column<int>("GroupProperty_id")
.Column<string>("GUIdentifier", column => column.WithLength(68))
);

SchemaBuilder.CreateTable("PropertyRecord",
Expand Down Expand Up @@ -203,9 +222,28 @@ public int Create() {
.WithPart("ProjectionPart")
.WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "5"))
.Creatable()
.Listable()
.DisplayedAs("Projection")
);

SchemaBuilder.CreateTable("NavigationQueryPartRecord",
table => table.ContentPartRecord()
.Column<int>("Items")
.Column<int>("Skip")
.Column<int>("QueryPartRecord_id")
);

ContentDefinitionManager.AlterTypeDefinition("NavigationQueryMenuItem",
cfg => cfg
.WithIdentity()
.WithPart("NavigationQueryPart")
.WithPart("MenuPart")
.WithPart("CommonPart")
.DisplayedAs("Query Link")
.WithSetting("Description", "Injects menu items from a Query")
.WithSetting("Stereotype", "MenuItem")
);

// Default Model Bindings - CommonPartRecord

_memberBindingRepository.Create(new MemberBindingRecord {
Expand Down Expand Up @@ -247,7 +285,7 @@ public int Create() {
Description = T("The text from the Body part").Text
});

return 1;
return 6;
}

public int UpdateFrom1() {
Expand All @@ -270,7 +308,7 @@ public int UpdateFrom1() {

ContentDefinitionManager.AlterTypeDefinition("ProjectionPage", cfg => cfg.Listable());

return 3;
return 2;
}

public int UpdateFrom2() {
Expand Down

0 comments on commit 50d416c

Please sign in to comment.