Add cookie banner versioning with JSONB snapshots

Introduce append-only cookie_banner_versions table with a JSONB
snapshot of consent-relevant configuration (privacy policy URL,
consent mode, expiry, categories and their cookies). Each version
has its own state (DRAFT/PUBLISHED) separate from the banner
lifecycle.

Replace the banner state enum (DRAFT/PUBLISHED/DISABLED) with a
simpler ACTIVE/INACTIVE toggle. Link consent records to the
specific published version the visitor accepted.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-13 12:42:35 +04:00
parent a153427a08
commit 88315f51e1
10 changed files with 790 additions and 63 deletions

View File

@@ -118,7 +118,7 @@ LIMIT 1;
return nil
}
func (b *CookieBanner) LoadPublishedByID(
func (b *CookieBanner) LoadActiveByID(
ctx context.Context,
conn pg.Querier,
bannerID gid.GID,
@@ -139,7 +139,7 @@ FROM
cookie_banners
WHERE
id = @banner_id
AND state = 'PUBLISHED'
AND state = 'ACTIVE'
LIMIT 1;
`