Files
petvity/drizzle/0001_lethal_mongu.sql
T
GandClaude Fable 5 bb5615c0fa feat(bookings,shop): calendar conflict blocking + Stripe payment integration (#25)
* feat(bookings,shop): calendar conflict blocking + Stripe payment integration

Tier-1 scheduling: the booking API now rejects (409) any request that
overlaps a professional's active bookings or their self-declared blocked
dates; vets/sitters manage blocked ranges at /portal/professional-profile
(new professional_blocked_dates table + /api/availability CRUD).

Payments: full Stripe Checkout flow, env-gated like Resend — without
STRIPE_SECRET_KEY nothing changes; with it, checkout redirects to Stripe,
the signed webhook (/api/payments/webhook) marks orders paid, and unpaid
orders stay payable from /portal/orders (Pay now + paid/awaiting badges).
orders gains paid_at + checkout_session_id.

Critical bug found by the smoke test: the login JWT callback wrote
resolveRole(email) back to the DB, silently DEMOTING every vet/sitter to
pet_owner at their next sign-in (residents were safe only because they
never log in). ADMIN_EMAILS now only promotes; professional roles survive.

Verified end-to-end locally: sitter registers → blocks dates → owner
booking overlap 409, blocked-dates 409, disjoint 201; checkout w/o keys
falls back to recorded orders. verify green (1209 tests incl. 12 new).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore: nudge CI (pull_request event was never delivered)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 13:49:47 +00:00

14 lines
830 B
SQL

CREATE TABLE "professional_blocked_dates" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"professional_id" uuid NOT NULL,
"start_date" date NOT NULL,
"end_date" date NOT NULL,
"reason" varchar(200),
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "orders" ADD COLUMN "paid_at" timestamp;--> statement-breakpoint
ALTER TABLE "orders" ADD COLUMN "checkout_session_id" varchar(255);--> statement-breakpoint
ALTER TABLE "professional_blocked_dates" ADD CONSTRAINT "professional_blocked_dates_professional_id_users_id_fk" FOREIGN KEY ("professional_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "professional_blocked_dates_professional_id_idx" ON "professional_blocked_dates" USING btree ("professional_id");