From 9af42b35659df29328a820a9ce70d34620a6db59 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Fri, 23 Aug 2024 13:29:49 +0200 Subject: [PATCH] fix: add migration to normalize api token types (#7974) Adds a migration to normalize api token types already in the database, to remove any weird casing issues as currently demonstrated on sandbox ![image](https://github.com/user-attachments/assets/ad14db22-114d-4de2-b952-722df9ae84a4) This is a companion piece to #7972 --- .../20240823091442-normalize-token-types.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/migrations/20240823091442-normalize-token-types.js diff --git a/src/migrations/20240823091442-normalize-token-types.js b/src/migrations/20240823091442-normalize-token-types.js new file mode 100644 index 0000000000..12e7b31af4 --- /dev/null +++ b/src/migrations/20240823091442-normalize-token-types.js @@ -0,0 +1,24 @@ +'use strict'; + +exports.up = function (db, cb) { + db.runSql( + ` + UPDATE api_tokens + SET type = 'client' + WHERE type = 'CLIENT'; + + UPDATE api_tokens + SET type = 'admin' + WHERE type = 'ADMIN'; + + UPDATE api_tokens + SET type = 'frontend' + WHERE type = 'FRONTEND'; + `, + cb, + ); +}; + +exports.down = function (db, cb) { + db.runSql(``, cb); +};