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

@@ -19,8 +19,9 @@ import "errors"
var (
ErrBannerNotFound = errors.New("cookie banner not found")
ErrCategoryNotFound = errors.New("cookie category not found")
ErrBannerNotDraft = errors.New("cookie banner is not in draft state")
ErrBannerAlreadyPublished = errors.New("cookie banner is already published")
ErrBannerAlreadyDisabled = errors.New("cookie banner is already disabled")
ErrVersionNotFound = errors.New("cookie banner version not found")
ErrBannerAlreadyActive = errors.New("cookie banner is already active")
ErrBannerAlreadyInactive = errors.New("cookie banner is already inactive")
ErrVersionNotPublished = errors.New("cookie banner version is not published")
ErrCannotDeleteRequiredCategory = errors.New("cannot delete required cookie category")
)