fix: webhook idempotency — unique index on stripe_customer_id + UPSERT + DB dedup on success page
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 12m44s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 12m44s
- Add partial unique index on api_keys(stripe_customer_id) WHERE NOT NULL - Use INSERT ... ON CONFLICT in createProKey for cross-pod dedup - Add findKeyByCustomerId() to query DB directly - Success page checks DB before creating key (survives pod restarts) - Refresh in-memory cache after UPSERT
This commit is contained in:
parent
e074562f73
commit
e9440a4e6a
3 changed files with 71 additions and 12 deletions
|
|
@ -162,6 +162,8 @@ export async function initDatabase(): Promise<void> {
|
|||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_email ON api_keys(email);
|
||||
CREATE INDEX IF NOT EXISTS idx_api_keys_stripe ON api_keys(stripe_customer_id);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_api_keys_stripe_unique
|
||||
ON api_keys(stripe_customer_id) WHERE stripe_customer_id IS NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS verifications (
|
||||
id SERIAL PRIMARY KEY,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue