From 50fe0bb74650a1bfa42571d8d5396f1aefe82482 Mon Sep 17 00:00:00 2001 From: Andy Copland Date: Tue, 1 Jul 2025 08:37:25 +0100 Subject: [PATCH] fix: Add OAuth support to search query source enum (#9511) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add 'oauth' to SearchQuery enum in server and client models - Add database migration to include 'oauth' in enum_search_queries_source - Fixes 400 validation error when OAuth users search with parameters 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude --- app/models/SearchQuery.ts | 2 +- ...0100046-add-oauth-to-search-queries-source.js | 16 ++++++++++++++++ server/models/SearchQuery.ts | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 server/migrations/20250630100046-add-oauth-to-search-queries-source.js diff --git a/app/models/SearchQuery.ts b/app/models/SearchQuery.ts index 558681926c..9091f5d718 100644 --- a/app/models/SearchQuery.ts +++ b/app/models/SearchQuery.ts @@ -12,7 +12,7 @@ class SearchQuery extends Model { /** * Where the query originated. */ - source: "api" | "app" | "slack"; + source: "api" | "app" | "slack" | "oauth"; delete = async () => { this.isSaving = true; diff --git a/server/migrations/20250630100046-add-oauth-to-search-queries-source.js b/server/migrations/20250630100046-add-oauth-to-search-queries-source.js new file mode 100644 index 0000000000..adf78a0c1b --- /dev/null +++ b/server/migrations/20250630100046-add-oauth-to-search-queries-source.js @@ -0,0 +1,16 @@ +'use strict'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up (queryInterface, Sequelize) { + await queryInterface.sequelize.query( + "ALTER TYPE enum_search_queries_source ADD VALUE 'oauth'" + ); + }, + + async down (queryInterface, Sequelize) { + // Note: PostgreSQL doesn't support removing enum values easily + // This would require recreating the enum type and updating all references + throw new Error('Cannot rollback adding enum value to PostgreSQL'); + } +}; diff --git a/server/models/SearchQuery.ts b/server/models/SearchQuery.ts index 4c1967f53b..adced150b0 100644 --- a/server/models/SearchQuery.ts +++ b/server/models/SearchQuery.ts @@ -38,7 +38,7 @@ class SearchQuery extends Model< /** * Where the query originated. */ - @Column(DataType.ENUM("slack", "app", "api")) + @Column(DataType.ENUM("slack", "app", "api", "oauth")) source: string; /**