From 9aa80c1bb029acc30d161ffd83988f6bc7822536 Mon Sep 17 00:00:00 2001 From: Recoup Agent Date: Wed, 18 Mar 2026 18:50:58 +0000 Subject: [PATCH] feat: migrate org API keys to personal account fb678396 Deprecating org API keys in favor of personal API keys. Updates all account_api_keys rows where account points to an organization (has members in account_organization_ids) to instead point to personal account fb678396-a68f-4294-ae50-b8cacf9ce77b. Co-Authored-By: Claude Sonnet 4.6 --- ...igrate_org_api_keys_to_personal_account.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 supabase/migrations/20260318000000_migrate_org_api_keys_to_personal_account.sql diff --git a/supabase/migrations/20260318000000_migrate_org_api_keys_to_personal_account.sql b/supabase/migrations/20260318000000_migrate_org_api_keys_to_personal_account.sql new file mode 100644 index 0000000..8e3221e --- /dev/null +++ b/supabase/migrations/20260318000000_migrate_org_api_keys_to_personal_account.sql @@ -0,0 +1,18 @@ +-- Migrate all org API keys to personal account fb678396-a68f-4294-ae50-b8cacf9ce77b +-- +-- Background: Org API keys are being deprecated in favor of personal API keys. +-- Org API keys are identified by their `account` column pointing to an organization +-- account (i.e., any account that appears as `organization_id` in +-- account_organization_ids, meaning it has members). +-- +-- This migration reassigns all such keys to the personal account +-- fb678396-a68f-4294-ae50-b8cacf9ce77b so they remain usable. + +UPDATE public.account_api_keys +SET account = 'fb678396-a68f-4294-ae50-b8cacf9ce77b' +WHERE account IN ( + SELECT DISTINCT organization_id + FROM public.account_organization_ids + WHERE organization_id IS NOT NULL +) +AND account != 'fb678396-a68f-4294-ae50-b8cacf9ce77b';