Skip to content

Commit 76f4ae6

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(tiktok): preserve routing backfill state
1 parent 6c2fb99 commit 76f4ae6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/db/migrations/0282_tiktok_routing_key.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
-- Resolve the server-attested TikTok open_id once at deploy time, like Slack's
22
-- team_id routing. Rows whose credential/account identity cannot be proven are
33
-- deliberately left unchanged so the migration never guesses a tenant key.
4-
CREATE TEMP TABLE "_tiktok_webhook_routing_backfill" ON COMMIT DROP AS
4+
-- migration-safe: session-local scratch table created only by this migration; no application code reads it.
5+
DROP TABLE IF EXISTS "_tiktok_webhook_routing_backfill";
6+
--> statement-breakpoint
7+
CREATE TEMP TABLE "_tiktok_webhook_routing_backfill" ON COMMIT PRESERVE ROWS AS
58
SELECT
69
"webhook"."id" AS "webhook_id",
710
"webhook"."workflow_id",
@@ -53,6 +56,9 @@ BEGIN
5356
RAISE NOTICE 'Migrated % TikTok webhook rows to routing_key', migrated_count;
5457
END $$;
5558
--> statement-breakpoint
59+
-- migration-safe: remove the session-local scratch table after the backfill completes.
60+
DROP TABLE IF EXISTS "_tiktok_webhook_routing_backfill";
61+
--> statement-breakpoint
5662
COMMIT;
5763
--> statement-breakpoint
5864
SET lock_timeout = 0;

0 commit comments

Comments
 (0)