Skip to content

Commit

Permalink
Add Parent_id index for Admin database (flyteorg#115)
Browse files Browse the repository at this point in the history
* Add Parent_id index for Admin database
  • Loading branch information
anandswaminathan authored Aug 14, 2020
1 parent 067dc91 commit eb9ec2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion pkg/repositories/config/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ var Migrations = []*gormigrate.Migration{
return tx.Model(&models.NodeExecution{}).DropColumn("cache_status").Error
},
},

{
ID: "2020-07-31-node-execution",
Migrate: func(tx *gorm.DB) error {
Expand All @@ -243,4 +242,13 @@ var Migrations = []*gormigrate.Migration{
return tx.Model(&models.NodeExecution{}).DropColumn("parent_id").DropColumn("node_execution_metadata").Error
},
},
{
ID: "2020-08-13-node-execution",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(&models.NodeExecution{}).Error
},
Rollback: func(tx *gorm.DB) error {
return tx.Model(&models.NodeExecution{}).DropColumn("parent_id").DropColumn("node_execution_metadata").Error
},
},
}
2 changes: 1 addition & 1 deletion pkg/repositories/models/node_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type NodeExecution struct {
// Metadata about the node execution.
NodeExecutionMetadata []byte
// Parent that spawned this node execution - value is empty for executions at level 0
ParentID *uint `sql:"default:null"`
ParentID *uint `sql:"default:null" gorm:"index"`
// List of child node executions - for cases like Dynamic task, sub workflow, etc
ChildNodeExecutions []NodeExecution `gorm:"foreignkey:ParentID"`
// The task execution (if any) which launched this node execution.
Expand Down
4 changes: 2 additions & 2 deletions tests/node_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func TestListNodeExecutionWithParent(t *testing.T) {
assert.Len(t, response.NodeExecutions, 2)
nodeExecutionResponse = response.NodeExecutions[0]
assert.True(t, proto.Equal(&core.NodeExecutionIdentifier{
NodeId: "child",
NodeId: "child2",
ExecutionId: nodeExecutionId.ExecutionId,
}, nodeExecutionResponse.Id))
assert.Equal(t, core.NodeExecution_RUNNING, nodeExecutionResponse.Closure.Phase)
Expand All @@ -356,7 +356,7 @@ func TestListNodeExecutionWithParent(t *testing.T) {

nodeExecutionResponse = response.NodeExecutions[1]
assert.True(t, proto.Equal(&core.NodeExecutionIdentifier{
NodeId: "child2",
NodeId: "child",
ExecutionId: nodeExecutionId.ExecutionId,
}, nodeExecutionResponse.Id))
assert.Equal(t, core.NodeExecution_RUNNING, nodeExecutionResponse.Closure.Phase)
Expand Down

0 comments on commit eb9ec2b

Please sign in to comment.