diff --git a/pkg/repositories/config/migration_models.go b/pkg/repositories/config/migration_models.go index 6c5769d3a..60c4920e6 100644 --- a/pkg/repositories/config/migration_models.go +++ b/pkg/repositories/config/migration_models.go @@ -54,7 +54,10 @@ type NodeExecution struct { type TaskExecutionKey struct { TaskKey - NodeExecutionKey + Project string `gorm:"primary_key;column:execution_project;index:idx_task_executions_exec"` + Domain string `gorm:"primary_key;column:execution_domain;index:idx_task_executions_exec"` + Name string `gorm:"primary_key;column:execution_name;index:idx_task_executions_exec"` + NodeID string `gorm:"primary_key;index:idx_task_executions_exec;index"` // *IMPORTANT* This is a pointer to an int in order to allow setting an empty ("0") value according to gorm convention. // Because RetryAttempt is part of the TaskExecution primary key is should *never* be null. RetryAttempt *uint32 `gorm:"primary_key;AUTO_INCREMENT:FALSE"` diff --git a/pkg/repositories/config/migrations.go b/pkg/repositories/config/migrations.go index b210b3b64..163e9d652 100644 --- a/pkg/repositories/config/migrations.go +++ b/pkg/repositories/config/migrations.go @@ -260,4 +260,13 @@ var Migrations = []*gormigrate.Migration{ return tx.Model(&models.Project{}).DropColumn("labels").Error }, }, + { + ID: "2020-09-01-task-exec-idx", + Migrate: func(tx *gorm.DB) error { + return tx.AutoMigrate(&TaskExecution{}).Error + }, + Rollback: func(tx *gorm.DB) error { + return tx.Model(&TaskExecution{}).RemoveIndex("idx_task_executions_exec").Error + }, + }, } diff --git a/tests/project.go b/tests/project.go index a799fb22c..686ef0eea 100644 --- a/tests/project.go +++ b/tests/project.go @@ -90,7 +90,7 @@ func TestUpdateProjectDescription(t *testing.T) { // Verify that the project's Name has not been modified but the Description has. updatedProject := projectsUpdated.Projects[0] - assert.Equal(t, updatedProject.Id, "potato") // unchanged + assert.Equal(t, updatedProject.Id, "potato") // unchanged assert.Equal(t, updatedProject.Name, "foobar") // changed assert.Equal(t, updatedProject.Description, "a-new-description") // changed @@ -148,8 +148,8 @@ func TestUpdateProjectLabels(t *testing.T) { // Check the name has been modified. // Verify that the project's Name has not been modified but the Description has. updatedProject := projectsUpdated.Projects[0] - assert.Equal(t, updatedProject.Id, "potato") // unchanged - assert.Equal(t, updatedProject.Name, "foobar") // changed + assert.Equal(t, updatedProject.Id, "potato") // unchanged + assert.Equal(t, updatedProject.Name, "foobar") // changed // Verify that the expected labels have been added to the project. labelsMap := updatedProject.Labels