exports.up = (pgm) => { pgm.sql(` -- Consent to the Brevo tracker, separate from marketing_consent (#56). -- -- Separate because GDPR requires consent to be granular: email marketing -- and behavioural tracking are two purposes with two recipients, and -- current EDPB guidance treats bundling tracking consent with subscription -- consent as invalid. Quebec's Law 25 s.8.1 goes further and requires -- profiling technology to be off until the person switches it on. -- -- DEFAULT FALSE is the part that must not be changed. Every existing -- customer arrives at false, which is both the honest answer — none of them -- were ever asked — and what Law 25 requires. A default of true would -- silently opt in the entire customer base to something nobody agreed to. ALTER TABLE customers ADD COLUMN IF NOT EXISTS analytics_consent BOOLEAN NOT NULL DEFAULT FALSE; -- When they agreed, and to exactly what wording. Same shape and same -- reasoning as the marketing_consent pair: the stored sentence is what -- makes the record say what the customer actually saw, so re-wording the -- consent later cannot retroactively broaden anyone's. -- -- Both nullable: a customer who has never consented has no date and no -- text, and inventing either would be a false record of consent. ALTER TABLE customers ADD COLUMN IF NOT EXISTS analytics_consent_at TIMESTAMPTZ; ALTER TABLE customers ADD COLUMN IF NOT EXISTS analytics_consent_text TEXT; `); }; exports.down = (pgm) => { pgm.sql(` ALTER TABLE customers DROP COLUMN IF EXISTS analytics_consent_text; ALTER TABLE customers DROP COLUMN IF EXISTS analytics_consent_at; ALTER TABLE customers DROP COLUMN IF EXISTS analytics_consent; `); };