From d1e4f31d07ae8d2129c0b745db6574a858df58db Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Wed, 25 Mar 2026 23:47:27 +0100 Subject: [PATCH] Fix empty search_engine_indexing on trust centers Trust centers were created without setting SearchEngineIndexing, defaulting to an empty string in the database. This caused scan errors when loading trust centers. Add a migration to fix corrupted rows, set a DEFAULT on the column, and add a CHECK constraint. Also set the field explicitly when creating new trust centers. Signed-off-by: Bryan Frimin --- pkg/coredata/migrations/20260325T120000Z.sql | 9 +++++++++ pkg/iam/organization_service.go | 17 +++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 pkg/coredata/migrations/20260325T120000Z.sql diff --git a/pkg/coredata/migrations/20260325T120000Z.sql b/pkg/coredata/migrations/20260325T120000Z.sql new file mode 100644 index 000000000..92968850e --- /dev/null +++ b/pkg/coredata/migrations/20260325T120000Z.sql @@ -0,0 +1,9 @@ +CREATE TYPE search_engine_indexing AS ENUM ('INDEXABLE', 'NOT_INDEXABLE'); + +UPDATE trust_centers +SET search_engine_indexing = 'NOT_INDEXABLE' +WHERE search_engine_indexing = ''; + +ALTER TABLE trust_centers +ALTER COLUMN search_engine_indexing TYPE search_engine_indexing +USING search_engine_indexing::search_engine_indexing; diff --git a/pkg/iam/organization_service.go b/pkg/iam/organization_service.go index ebe832380..da674012d 100644 --- a/pkg/iam/organization_service.go +++ b/pkg/iam/organization_service.go @@ -489,14 +489,15 @@ func (s *OrganizationService) CreateOrganization( } trustCenter = &coredata.TrustCenter{ - ID: gid.New(tenantID, coredata.TrustCenterEntityType), - OrganizationID: organization.ID, - TenantID: organization.TenantID, - Active: false, - Slug: slug.Make(organization.Name), - MailingListID: &mailingList.ID, - CreatedAt: now, - UpdatedAt: now, + ID: gid.New(tenantID, coredata.TrustCenterEntityType), + OrganizationID: organization.ID, + TenantID: organization.TenantID, + Active: false, + Slug: slug.Make(organization.Name), + SearchEngineIndexing: coredata.SearchEngineIndexingNotIndexable, + MailingListID: &mailingList.ID, + CreatedAt: now, + UpdatedAt: now, } logoFile *coredata.File