Skip to content

chore: add index workflowName,project #1388

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

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Create index "workflow_name_project_organization_id" to table: "workflows"
CREATE UNIQUE INDEX "workflow_name_project_organization_id" ON "workflows" ("name", "project", "organization_id") WHERE (deleted_at IS NULL);
3 changes: 2 additions & 1 deletion app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:/GVJXP6pdXbjL89PpRrAKyL9sg5T8mS0Vnrb6QjoQNg=
h1:ZKwKoug7zWvV7LPmmO8BJWnL21uzs9lj+6h4H99MDBs=
20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M=
20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g=
20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI=
Expand Down Expand Up @@ -43,3 +43,4 @@ h1:/GVJXP6pdXbjL89PpRrAKyL9sg5T8mS0Vnrb6QjoQNg=
20240819104758.sql h1:bpAwdQakxcXNy5ZfmA/tAzx+lIQBPs2LWs6wk2QCPTw=
20240827110459.sql h1:opB+0UvGuYIyi1B3BEyh06HNzon3V867QHsc8yrsTuE=
20240920193509.sql h1:FREEMo5oD//cf+6iq72YgbVJgXN/fuy7DB/jvx6NgKM=
20241011075107.sql h1:8UrMNKA0QAKkhfdetnNCZfI7DBOTKLLxsqqH+c8VhdU=
8 changes: 8 additions & 0 deletions app/controlplane/pkg/data/ent/migrate/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ var (
},
},
Indexes: []*schema.Index{
{
Name: "workflow_name_project_organization_id",
Unique: true,
Columns: []*schema.Column{WorkflowsColumns[1], WorkflowsColumns[2], WorkflowsColumns[9]},
Annotation: &entsql.IndexAnnotation{
Where: "deleted_at IS NULL",
},
},
{
Name: "workflow_name_organization_id",
Unique: true,
Expand Down
4 changes: 4 additions & 0 deletions app/controlplane/pkg/data/ent/schema/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func (Workflow) Edges() []ent.Edge {

func (Workflow) Indexes() []ent.Index {
return []ent.Index{
index.Fields("name", "project").Edges("organization").Unique().Annotations(
entsql.IndexWhere("deleted_at IS NULL"),
Copy link
Member

Choose a reason for hiding this comment

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

I love this!

),
// DEPRECATED, will be replaced by the above index
// names are unique within a organization and affects only to non-deleted items
index.Fields("name").Edges("organization").Unique().Annotations(
entsql.IndexWhere("deleted_at IS NULL"),
Expand Down
Loading