Skip to content

Commit

Permalink
Add created_at index to executions (flyteorg#387)
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <katroganGH@gmail.com>
  • Loading branch information
katrogan authored Apr 4, 2022
1 parent 07c4161 commit 052435f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions flyteadmin/pkg/repositories/config/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,16 @@ var Migrations = []*gormigrate.Migration{
return tx.Table("node_execution").Migrator().DropColumn(&NodeExecution{}, "internal_data")
},
},
// Add created_at index to the execution model.
{
ID: "2022-04-04-execution-created-at-index",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(&models.Execution{})
},
Rollback: func(tx *gorm.DB) error {
return tx.Model(&models.Execution{}).Migrator().DropIndex(&models.Execution{}, "idx_executions_created_at")
},
},
}

func alterTableColumnType(db *sql.DB, columnName, columnType string) error {
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/pkg/repositories/models/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Execution struct {
StartedAt *time.Time
// Corresponds to the CreatedAt field in the Execution closure.
// Prefixed with Execution to avoid clashes with gorm.Model CreatedAt
ExecutionCreatedAt *time.Time
ExecutionCreatedAt *time.Time `gorm:"index:idx_executions_created_at"`
// Corresponds to the UpdatedAt field in the Execution closure
// Prefixed with Execution to avoid clashes with gorm.Model UpdatedAt
ExecutionUpdatedAt *time.Time
Expand Down

0 comments on commit 052435f

Please sign in to comment.