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:
@@ -39,16 +39,17 @@ type (
|
|||||||
CookieItems []CookieItem
|
CookieItems []CookieItem
|
||||||
|
|
||||||
CookieCategory struct {
|
CookieCategory struct {
|
||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
OrganizationID gid.GID `db:"organization_id"`
|
OrganizationID gid.GID `db:"organization_id"`
|
||||||
CookieBannerID gid.GID `db:"cookie_banner_id"`
|
CookieBannerID gid.GID `db:"cookie_banner_id"`
|
||||||
Name string `db:"name"`
|
Name string `db:"name"`
|
||||||
Slug string `db:"slug"`
|
Slug string `db:"slug"`
|
||||||
Description string `db:"description"`
|
Description string `db:"description"`
|
||||||
Kind CookieCategoryKind `db:"kind"`
|
Kind CookieCategoryKind `db:"kind"`
|
||||||
Rank int `db:"rank"`
|
Rank int `db:"rank"`
|
||||||
CreatedAt time.Time `db:"created_at"`
|
GCMConsentTypes []string `db:"gcm_consent_types"`
|
||||||
UpdatedAt time.Time `db:"updated_at"`
|
CreatedAt time.Time `db:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
CookieCategories []*CookieCategory
|
CookieCategories []*CookieCategory
|
||||||
@@ -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,23 +301,25 @@ INSERT INTO cookie_categories (
|
|||||||
@description,
|
@description,
|
||||||
@kind,
|
@kind,
|
||||||
@rank,
|
@rank,
|
||||||
|
@gcm_consent_types,
|
||||||
@created_at,
|
@created_at,
|
||||||
@updated_at
|
@updated_at
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
|
|
||||||
args := pgx.StrictNamedArgs{
|
args := pgx.StrictNamedArgs{
|
||||||
"id": c.ID,
|
"id": c.ID,
|
||||||
"tenant_id": scope.GetTenantID(),
|
"tenant_id": scope.GetTenantID(),
|
||||||
"organization_id": c.OrganizationID,
|
"organization_id": c.OrganizationID,
|
||||||
"cookie_banner_id": c.CookieBannerID,
|
"cookie_banner_id": c.CookieBannerID,
|
||||||
"name": c.Name,
|
"name": c.Name,
|
||||||
"slug": c.Slug,
|
"slug": c.Slug,
|
||||||
"description": c.Description,
|
"description": c.Description,
|
||||||
"kind": c.Kind,
|
"kind": c.Kind,
|
||||||
"rank": c.Rank,
|
"rank": c.Rank,
|
||||||
"created_at": c.CreatedAt,
|
"gcm_consent_types": c.GCMConsentTypes,
|
||||||
"updated_at": c.UpdatedAt,
|
"created_at": c.CreatedAt,
|
||||||
|
"updated_at": c.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := tx.Exec(ctx, q, args)
|
_, err := tx.Exec(ctx, q, args)
|
||||||
@@ -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
|
||||||
@@ -348,11 +356,12 @@ WHERE
|
|||||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||||
|
|
||||||
args := pgx.StrictNamedArgs{
|
args := pgx.StrictNamedArgs{
|
||||||
"id": c.ID,
|
"id": c.ID,
|
||||||
"name": c.Name,
|
"name": c.Name,
|
||||||
"slug": c.Slug,
|
"slug": c.Slug,
|
||||||
"description": c.Description,
|
"description": c.Description,
|
||||||
"updated_at": c.UpdatedAt,
|
"gcm_consent_types": c.GCMConsentTypes,
|
||||||
|
"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
|
||||||
|
|||||||
16
pkg/coredata/migrations/20260424T093655Z.sql
Normal file
16
pkg/coredata/migrations/20260424T093655Z.sql
Normal 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;
|
||||||
Reference in New Issue
Block a user