From 92bf975ac198f8d17d4061c11fe5b08262aa59d6 Mon Sep 17 00:00:00 2001 From: Mason Malone <651224+MasonM@users.noreply.github.com> Date: Thu, 24 Oct 2024 01:02:15 -0700 Subject: [PATCH] fix!: migrate `argo_archived_workflows.workflow` to `jsonb` (#13779) Signed-off-by: Mason Malone <651224+MasonM@users.noreply.github.com> --- persist/sqldb/migrate.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/persist/sqldb/migrate.go b/persist/sqldb/migrate.go index 45c908cc87de..633dfd2ff31a 100644 --- a/persist/sqldb/migrate.go +++ b/persist/sqldb/migrate.go @@ -25,6 +25,12 @@ type change interface { apply(session db.Session) error } +type noop struct{} + +func (s noop) apply(session db.Session) error { + return nil +} + func ternary(condition bool, left, right change) change { if condition { return left @@ -258,6 +264,11 @@ func (m migrate) Exec(ctx context.Context) (err error) { // add indexes for list archived workflow performance. #8836 ansiSQLChange(`create index argo_archived_workflows_i4 on argo_archived_workflows (startedat)`), ansiSQLChange(`create index argo_archived_workflows_labels_i1 on argo_archived_workflows_labels (name,value)`), + // PostgreSQL only: convert argo_archived_workflows.workflow column to JSONB for performance and consistency with MySQL. #13779 + ternary(dbType == MySQL, + noop{}, + ansiSQLChange(`alter table argo_archived_workflows alter column workflow set data type jsonb using workflow::jsonb`), + ), } { err := m.applyChange(changeSchemaVersion, change) if err != nil {