Skip to content

Commit 92de8af

Browse files
authored
feat(workflow-runs): Add index on foreign key (#1277)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent f2c8f48 commit 92de8af

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Create index "workflowrun_created_at_workflow_workflowruns" to table: "workflow_runs"
2+
CREATE INDEX "workflowrun_created_at_workflow_workflowruns" ON "workflow_runs" ("created_at", "workflow_workflowruns");

app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:JssL6GSWWxZ/FmPomukKpn65E/hnMXJXaoOdrG5ARnc=
1+
h1:3t9rfP6n9TkogTDvCGpnZvdVjpgRnb5eeXjA753TFvg=
22
20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M=
33
20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g=
44
20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI=
@@ -41,3 +41,4 @@ h1:JssL6GSWWxZ/FmPomukKpn65E/hnMXJXaoOdrG5ARnc=
4141
20240816140029.sql h1:oz/iOx8gKmhPR8QhXT4t6G2Aun8FZufR/aPQsJHZ7P0=
4242
20240817110515.sql h1:TpKcnvfG41SUC4rNMQ9YFNuVsDB0A408hCI5qaoRzQo=
4343
20240819104758.sql h1:bpAwdQakxcXNy5ZfmA/tAzx+lIQBPs2LWs6wk2QCPTw=
44+
20240827110459.sql h1:opB+0UvGuYIyi1B3BEyh06HNzon3V867QHsc8yrsTuE=

app/controlplane/pkg/data/ent/migrate/schema.go

+5
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,11 @@ var (
493493
Unique: false,
494494
Columns: []*schema.Column{WorkflowRunsColumns[12]},
495495
},
496+
{
497+
Name: "workflowrun_created_at_workflow_workflowruns",
498+
Unique: false,
499+
Columns: []*schema.Column{WorkflowRunsColumns[1], WorkflowRunsColumns[12]},
500+
},
496501
},
497502
}
498503
// ReferrerReferencesColumns holds the columns for the "referrer_references" table.

app/controlplane/pkg/data/ent/schema/workflowrun.go

+2
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ func (WorkflowRun) Indexes() []ent.Index {
7979
index.Fields("created_at", "state"),
8080
index.Fields("attestation_digest"),
8181
index.Edges("workflow"),
82+
// DailyRun counts
83+
index.Edges("workflow").Fields("created_at"),
8284
}
8385
}

0 commit comments

Comments
 (0)