From 2b15a1684c9ca83cdc479be046a6cb2adf4f09ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 24 Apr 2026 13:40:28 +0400 Subject: [PATCH] Add gcm_consent_types column to cookie_categories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stores the Google Consent Mode v2 consent type mapping per cookie category so each category can declare which GCM signals it controls (e.g. analytics_storage, ad_storage). Signed-off-by: Émile Ré --- pkg/coredata/cookie_category.go | 62 ++++++++++++-------- pkg/coredata/migrations/20260424T093655Z.sql | 16 +++++ 2 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 pkg/coredata/migrations/20260424T093655Z.sql diff --git a/pkg/coredata/cookie_category.go b/pkg/coredata/cookie_category.go index b52f50db2..76ca10d4d 100644 --- a/pkg/coredata/cookie_category.go +++ b/pkg/coredata/cookie_category.go @@ -39,16 +39,17 @@ type ( CookieItems []CookieItem CookieCategory struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - CookieBannerID gid.GID `db:"cookie_banner_id"` - Name string `db:"name"` - Slug string `db:"slug"` - Description string `db:"description"` - Kind CookieCategoryKind `db:"kind"` - Rank int `db:"rank"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CookieBannerID gid.GID `db:"cookie_banner_id"` + Name string `db:"name"` + Slug string `db:"slug"` + Description string `db:"description"` + Kind CookieCategoryKind `db:"kind"` + Rank int `db:"rank"` + GCMConsentTypes []string `db:"gcm_consent_types"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } CookieCategories []*CookieCategory @@ -109,6 +110,7 @@ SELECT description, kind, rank, + gcm_consent_types, created_at, updated_at FROM @@ -159,6 +161,7 @@ SELECT description, kind, rank, + gcm_consent_types, created_at, updated_at FROM @@ -237,6 +240,7 @@ SELECT description, kind, rank, + gcm_consent_types, created_at, updated_at FROM @@ -284,6 +288,7 @@ INSERT INTO cookie_categories ( description, kind, rank, + gcm_consent_types, created_at, updated_at ) VALUES ( @@ -296,23 +301,25 @@ INSERT INTO cookie_categories ( @description, @kind, @rank, + @gcm_consent_types, @created_at, @updated_at ) ` args := pgx.StrictNamedArgs{ - "id": c.ID, - "tenant_id": scope.GetTenantID(), - "organization_id": c.OrganizationID, - "cookie_banner_id": c.CookieBannerID, - "name": c.Name, - "slug": c.Slug, - "description": c.Description, - "kind": c.Kind, - "rank": c.Rank, - "created_at": c.CreatedAt, - "updated_at": c.UpdatedAt, + "id": c.ID, + "tenant_id": scope.GetTenantID(), + "organization_id": c.OrganizationID, + "cookie_banner_id": c.CookieBannerID, + "name": c.Name, + "slug": c.Slug, + "description": c.Description, + "kind": c.Kind, + "rank": c.Rank, + "gcm_consent_types": c.GCMConsentTypes, + "created_at": c.CreatedAt, + "updated_at": c.UpdatedAt, } _, err := tx.Exec(ctx, q, args) @@ -339,6 +346,7 @@ SET name = @name, slug = @slug, description = @description, + gcm_consent_types = @gcm_consent_types, updated_at = @updated_at WHERE %s @@ -348,11 +356,12 @@ WHERE q = fmt.Sprintf(q, scope.SQLFragment()) args := pgx.StrictNamedArgs{ - "id": c.ID, - "name": c.Name, - "slug": c.Slug, - "description": c.Description, - "updated_at": c.UpdatedAt, + "id": c.ID, + "name": c.Name, + "slug": c.Slug, + "description": c.Description, + "gcm_consent_types": c.GCMConsentTypes, + "updated_at": c.UpdatedAt, } maps.Copy(args, scope.SQLArguments()) @@ -467,6 +476,7 @@ SELECT description, kind, rank, + gcm_consent_types, created_at, updated_at FROM diff --git a/pkg/coredata/migrations/20260424T093655Z.sql b/pkg/coredata/migrations/20260424T093655Z.sql new file mode 100644 index 000000000..e71faaedd --- /dev/null +++ b/pkg/coredata/migrations/20260424T093655Z.sql @@ -0,0 +1,16 @@ +-- Copyright (c) 2026 Probo Inc . +-- +-- Permission to use, copy, modify, and/or distribute this software for any +-- purpose with or without fee is hereby granted, provided that the above +-- copyright notice and this permission notice appear in all copies. +-- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +-- PERFORMANCE OF THIS SOFTWARE. + +ALTER TABLE cookie_categories ADD COLUMN gcm_consent_types TEXT[] NOT NULL DEFAULT '{}'; +ALTER TABLE cookie_categories ALTER COLUMN gcm_consent_types DROP DEFAULT;