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 <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-25 23:47:27 +01:00
parent c5d4912c4c
commit d1e4f31d07
2 changed files with 18 additions and 8 deletions

View File

@@ -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;

View File

@@ -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