Add gcm_consent_types column to cookie_categories

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é <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-24 13:40:28 +04:00
parent ab5654f6e5
commit 2b15a1684c
2 changed files with 52 additions and 26 deletions

View File

@@ -47,6 +47,7 @@ type (
Description string `db:"description"` Description string `db:"description"`
Kind CookieCategoryKind `db:"kind"` Kind CookieCategoryKind `db:"kind"`
Rank int `db:"rank"` Rank int `db:"rank"`
GCMConsentTypes []string `db:"gcm_consent_types"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"` UpdatedAt time.Time `db:"updated_at"`
} }
@@ -109,6 +110,7 @@ SELECT
description, description,
kind, kind,
rank, rank,
gcm_consent_types,
created_at, created_at,
updated_at updated_at
FROM FROM
@@ -159,6 +161,7 @@ SELECT
description, description,
kind, kind,
rank, rank,
gcm_consent_types,
created_at, created_at,
updated_at updated_at
FROM FROM
@@ -237,6 +240,7 @@ SELECT
description, description,
kind, kind,
rank, rank,
gcm_consent_types,
created_at, created_at,
updated_at updated_at
FROM FROM
@@ -284,6 +288,7 @@ INSERT INTO cookie_categories (
description, description,
kind, kind,
rank, rank,
gcm_consent_types,
created_at, created_at,
updated_at updated_at
) VALUES ( ) VALUES (
@@ -296,6 +301,7 @@ INSERT INTO cookie_categories (
@description, @description,
@kind, @kind,
@rank, @rank,
@gcm_consent_types,
@created_at, @created_at,
@updated_at @updated_at
) )
@@ -311,6 +317,7 @@ INSERT INTO cookie_categories (
"description": c.Description, "description": c.Description,
"kind": c.Kind, "kind": c.Kind,
"rank": c.Rank, "rank": c.Rank,
"gcm_consent_types": c.GCMConsentTypes,
"created_at": c.CreatedAt, "created_at": c.CreatedAt,
"updated_at": c.UpdatedAt, "updated_at": c.UpdatedAt,
} }
@@ -339,6 +346,7 @@ SET
name = @name, name = @name,
slug = @slug, slug = @slug,
description = @description, description = @description,
gcm_consent_types = @gcm_consent_types,
updated_at = @updated_at updated_at = @updated_at
WHERE WHERE
%s %s
@@ -352,6 +360,7 @@ WHERE
"name": c.Name, "name": c.Name,
"slug": c.Slug, "slug": c.Slug,
"description": c.Description, "description": c.Description,
"gcm_consent_types": c.GCMConsentTypes,
"updated_at": c.UpdatedAt, "updated_at": c.UpdatedAt,
} }
maps.Copy(args, scope.SQLArguments()) maps.Copy(args, scope.SQLArguments())
@@ -467,6 +476,7 @@ SELECT
description, description,
kind, kind,
rank, rank,
gcm_consent_types,
created_at, created_at,
updated_at updated_at
FROM FROM

View File

@@ -0,0 +1,16 @@
-- Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
--
-- 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;