From ea4144a09ce0397afe0c5a16a972bf94d9828be6 Mon Sep 17 00:00:00 2001 From: camlyall Date: Thu, 27 Jul 2023 15:39:48 +0000 Subject: [PATCH] adapt decision_token to comply with MySQL8 --- internal/collection/goa.go | 2 +- internal/collection/types.go | 2 +- internal/db/migrations/1690467272_task_token_encoding.down.sql | 1 + internal/db/migrations/1690467272_task_token_encoding.up.sql | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 internal/db/migrations/1690467272_task_token_encoding.down.sql create mode 100644 internal/db/migrations/1690467272_task_token_encoding.up.sql diff --git a/internal/collection/goa.go b/internal/collection/goa.go index 379fbc6f..c543a151 100644 --- a/internal/collection/goa.go +++ b/internal/collection/goa.go @@ -394,7 +394,7 @@ func (w *goaWrapper) Decide(ctx context.Context, payload *goacollection.DecidePa return err } - if c.DecisionToken == "" || c.Status != StatusPending { + if c.DecisionToken == nil || c.Status != StatusPending { return goacollection.MakeNotValid(errors.New("collection is not awaiting decision")) } diff --git a/internal/collection/types.go b/internal/collection/types.go index de917079..bbacbb8e 100644 --- a/internal/collection/types.go +++ b/internal/collection/types.go @@ -17,7 +17,7 @@ type Collection struct { AIPID string `db:"aip_id"` OriginalID string `db:"original_id"` PipelineID string `db:"pipeline_id"` - DecisionToken string `db:"decision_token"` + DecisionToken []byte `db:"decision_token"` Status Status `db:"status"` // It defaults to CURRENT_TIMESTAMP(6) so populated as soon as possible. diff --git a/internal/db/migrations/1690467272_task_token_encoding.down.sql b/internal/db/migrations/1690467272_task_token_encoding.down.sql new file mode 100644 index 00000000..4cda9294 --- /dev/null +++ b/internal/db/migrations/1690467272_task_token_encoding.down.sql @@ -0,0 +1 @@ +ALTER TABLE collection CHANGE `decision_token` `decision_token` TEXT NOT NULL; diff --git a/internal/db/migrations/1690467272_task_token_encoding.up.sql b/internal/db/migrations/1690467272_task_token_encoding.up.sql new file mode 100644 index 00000000..800b71d2 --- /dev/null +++ b/internal/db/migrations/1690467272_task_token_encoding.up.sql @@ -0,0 +1 @@ +ALTER TABLE collection CHANGE `decision_token` `decision_token` VARBINARY(255);