Files
accounted/supabase/migrations/20260808150100_shopify_sync_capability_backfill.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

30 lines
1.2 KiB
SQL

-- Backfill capability_grants for the new 'shopify_sync' capability.
--
-- shopify_sync joins PAID_CAPABILITIES, but existing companies' grants were
-- written by the billing webhook / trial seeding BEFORE this key existed, and
-- are only refreshed on the next subscription event. Without a backfill,
-- every current payer and trialer would see the Shopify integration as not
-- entitled until their next webhook. Mirror each existing bank_sync grant
-- (the same sibling used by the stripe_payments and woocommerce_sync
-- backfills, 20260712100100 / 20260806170100) with identical scope, source
-- and expiry, so entitlement state stays exactly aligned.
--
-- Idempotent: the (scope, key, source) unique index makes re-runs no-ops.
insert into public.capability_grants
(company_id, team_id, capability_key, source, granted_at, expires_at, metadata)
select
g.company_id,
g.team_id,
'shopify_sync',
g.source,
g.granted_at,
g.expires_at,
jsonb_build_object(
'backfilled_from', 'bank_sync',
'backfill_migration', '20260808150100'
)
from public.capability_grants g
where g.capability_key = 'bank_sync'
on conflict (company_id, team_id, capability_key, source) do nothing;