8f06f32e7d
- Wrap idempotency check + processRefund() + db.insert() in db.transaction() - This prevents duplicate Stripe refunds if the DB insert fails after Stripe processes the refund - Add migration 0027_refunds for the refunds table (was missing) - Removes out-of-scope changes from PR #278 (csrf.ts, appointmentGroups, appointments, book, groomingLogs, services, stripe-webhooks) Fixes GRO-637 per CTO review Co-Authored-By: Paperclip <noreply@paperclip.ing>
12 lines
442 B
SQL
12 lines
442 B
SQL
CREATE TABLE "refunds" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
"invoice_id" uuid NOT NULL REFERENCES "invoices"("id") ON DELETE RESTRICT,
|
|
"stripe_refund_id" text NOT NULL,
|
|
"idempotency_key" text UNIQUE,
|
|
"amount_cents" integer,
|
|
"created_at" timestamp NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX "idx_refunds_invoice_id" ON "refunds"("invoice_id");
|
|
CREATE INDEX "idx_refunds_idempotency_key" ON "refunds"("idempotency_key");
|