From c5cd66d5f0d82621caa5d5f4ae27c5330f48bb71 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 23 Oct 2026 07:24:44 +0000 Subject: [PATCH 1/2] Apply DB-05 duplicate-index drop and promo_redeem_failures primary key as migrations Adam approved these on 23 Oct 2026. Both move from supabase/proposed/ to supabase/migrations/ under new timestamps so main and the hosted projects stay in sync. DB-04 (staging_auto_admin) was run by hand on staging as its header requires and is removed from proposed/. DB-03 stays proposed. --- .../20261023073000_drop_duplicate_indexes.sql} | 4 ++-- ...3073100_promo_redeem_failures_primary_key.sql} | 3 ++- .../20261023060100_drop_staging_auto_admin.sql | 15 --------------- 3 files changed, 4 insertions(+), 18 deletions(-) rename supabase/{proposed/20261023060200_drop_duplicate_indexes.sql => migrations/20261023073000_drop_duplicate_indexes.sql} (94%) rename supabase/{proposed/20261023060300_promo_redeem_failures_primary_key.sql => migrations/20261023073100_promo_redeem_failures_primary_key.sql} (86%) delete mode 100644 supabase/proposed/20261023060100_drop_staging_auto_admin.sql diff --git a/supabase/proposed/20261023060200_drop_duplicate_indexes.sql b/supabase/migrations/20261023073000_drop_duplicate_indexes.sql similarity index 94% rename from supabase/proposed/20261023060200_drop_duplicate_indexes.sql rename to supabase/migrations/20261023073000_drop_duplicate_indexes.sql index 20fba4394..abdf5e178 100644 --- a/supabase/proposed/20261023060200_drop_duplicate_indexes.sql +++ b/supabase/migrations/20261023073000_drop_duplicate_indexes.sql @@ -1,5 +1,5 @@ --- DB-05 (proposed, destructive): drop indexes that duplicate another index --- on the same table and column. +-- DB-05: drop indexes that duplicate another index on the same table and +-- column. Approved by Adam 23 Oct 2026; moved from supabase/proposed/. -- -- subscriptions idx_subscriptions_stripe_customer duplicates -- idx_subscriptions_stripe_customer_id (both plain diff --git a/supabase/proposed/20261023060300_promo_redeem_failures_primary_key.sql b/supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql similarity index 86% rename from supabase/proposed/20261023060300_promo_redeem_failures_primary_key.sql rename to supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql index f79ecc16c..f0a5c2474 100644 --- a/supabase/proposed/20261023060300_promo_redeem_failures_primary_key.sql +++ b/supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql @@ -1,4 +1,5 @@ --- DB-05 (proposed): give private.promo_redeem_failures a primary key. +-- DB-05: give private.promo_redeem_failures a primary key (approved by Adam +-- 23 Oct 2026; moved from supabase/proposed/). -- -- It is the one table without a primary key. Its natural columns -- (user_id, failed_at) can repeat when two failures share a timestamp, so a diff --git a/supabase/proposed/20261023060100_drop_staging_auto_admin.sql b/supabase/proposed/20261023060100_drop_staging_auto_admin.sql deleted file mode 100644 index a205f0146..000000000 --- a/supabase/proposed/20261023060100_drop_staging_auto_admin.sql +++ /dev/null @@ -1,15 +0,0 @@ --- DB-04 (proposed, destructive, STAGING ONLY: brifeyypjauyusmkptkx). --- --- staging_auto_admin() is left over from a trigger that was dropped by hand --- on staging. It does not exist on production or anywhere in --- supabase/migrations, so it must never be added to migrations. Run this by --- hand in the staging SQL editor. Check first that no trigger still uses it: --- --- SELECT tgname, tgrelid::regclass FROM pg_trigger t --- JOIN pg_proc p ON p.oid = t.tgfoid WHERE p.proname = 'staging_auto_admin'; --- --- That query must return no rows; without CASCADE the drop fails otherwise. --- `\df public.staging_auto_admin` should show it with no arguments; if it --- takes any, add them to the DROP below, or IF EXISTS skips it silently. - -DROP FUNCTION IF EXISTS public.staging_auto_admin(); From d73493827e93efaf744b53c36daef5fb0e9416ed Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 23 Oct 2026 07:27:15 +0000 Subject: [PATCH 2/2] Silence squawk on the promo_redeem_failures key with the reason --- .../20261023073100_promo_redeem_failures_primary_key.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql b/supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql index f0a5c2474..bf76d11aa 100644 --- a/supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql +++ b/supabase/migrations/20261023073100_promo_redeem_failures_primary_key.sql @@ -11,5 +11,7 @@ -- IF NOT EXISTS skips the whole statement, primary key included; check with -- `\d private.promo_redeem_failures` first. -ALTER TABLE private.promo_redeem_failures - ADD COLUMN IF NOT EXISTS id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY; +-- The rewrite and lock are accepted: the table holds a handful of rows +-- (1 on production on 23 Oct 2026) and only promo redemption writes to it. +-- squawk-ignore adding-field-with-default,adding-serial-primary-key-field +ALTER TABLE private.promo_redeem_failures ADD COLUMN IF NOT EXISTS id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY;