From 4b0d0cf0bd8a9ef5b1743a937ba560c3c457bd9e Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Thu, 11 Jun 2026 08:54:35 +0200 Subject: [PATCH] Default active to TRUE for access entries Drivers that cannot determine account status leave Active nil. Rather than surfacing NULL in the database, treat an absent signal as active (the account appeared in the source listing). - Migration: NOT NULL DEFAULT TRUE on the active column - Insert/upsert SQL: COALESCE(@active, TRUE) on write - Fix new(true) in test (not valid Go; use &activeTrue) Signed-off-by: Bryan Frimin --- pkg/coredata/access_entry.go | 4 ++-- pkg/coredata/access_entry_upsert_test.go | 3 ++- pkg/coredata/migrations/20260611T000000Z.sql | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/coredata/access_entry.go b/pkg/coredata/access_entry.go index df888911f..8f5315953 100644 --- a/pkg/coredata/access_entry.go +++ b/pkg/coredata/access_entry.go @@ -228,7 +228,7 @@ VALUES ( @mfa_status, @auth_method, @account_type, - @active, + COALESCE(@active, TRUE), @last_login, @account_created_at, @external_id, @@ -665,7 +665,7 @@ INSERT INTO access_entries ( @mfa_status, @auth_method, @account_type, - @active, + COALESCE(@active, TRUE), @last_login, @account_created_at, @external_id, diff --git a/pkg/coredata/access_entry_upsert_test.go b/pkg/coredata/access_entry_upsert_test.go index 788e4b5fe..5d7ed2c77 100644 --- a/pkg/coredata/access_entry_upsert_test.go +++ b/pkg/coredata/access_entry_upsert_test.go @@ -441,6 +441,7 @@ func TestAccessEntry_Upsert_InsertsActiveAccount(t *testing.T) { tenantID := fx.scope.GetTenantID() t0 := time.Now().UTC().Truncate(time.Microsecond) + activeTrue := true entryID := gid.New(tenantID, coredata.AccessEntryEntityType) entry := &coredata.AccessEntry{ ID: entryID, @@ -453,7 +454,7 @@ func TestAccessEntry_Upsert_InsertsActiveAccount(t *testing.T) { MFAStatus: coredata.MFAStatusUnknown, AuthMethod: coredata.AccessEntryAuthMethodUnknown, AccountType: coredata.AccessEntryAccountTypeUser, - Active: new(true), + Active: &activeTrue, ExternalID: "ext-active", AccountKey: fx.accountKey, IncrementalTag: coredata.AccessEntryIncrementalTagNew, diff --git a/pkg/coredata/migrations/20260611T000000Z.sql b/pkg/coredata/migrations/20260611T000000Z.sql index 9352941c6..bbb52985a 100644 --- a/pkg/coredata/migrations/20260611T000000Z.sql +++ b/pkg/coredata/migrations/20260611T000000Z.sql @@ -13,4 +13,4 @@ -- PERFORMANCE OF THIS SOFTWARE. ALTER TABLE access_entries - ADD COLUMN active BOOLEAN; + ADD COLUMN active BOOLEAN NOT NULL DEFAULT TRUE;