Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,11 +1,15 @@
|
||||
-- AK-P16b · P16 Booking — HARD DOUBLE-BOOKING GUARD (deferred, NOT in the Prisma schema)
|
||||
-- AK-P16b · P16 Booking — HARD DOUBLE-BOOKING GUARD (NOT in the Prisma schema)
|
||||
-- =============================================================================
|
||||
-- SHIPPED: since 20260717090000_ak_p16b_booking_overlap_constraint this
|
||||
-- constraint is part of the tracked migration chain (that migration is the
|
||||
-- authoritative copy, incl. a pre-flight overlap check). This file remains the
|
||||
-- feature-branch template for `psql -f` on db-push-only databases.
|
||||
--
|
||||
-- The race-protection backstop for DoD 2: a PostgreSQL EXCLUDE USING gist
|
||||
-- constraint that makes it physically impossible to persist two OVERLAPPING active
|
||||
-- appointments for the SAME provider. This cannot be expressed in the Prisma schema
|
||||
-- (Prisma has no exclusion-constraint primitive), so — like the RLS block — it
|
||||
-- ships out-of-band: `psql -f` on the feature branch, folded into the merge
|
||||
-- migration at main-merge (AD-21).
|
||||
-- appointments for the SAME provider WITHIN A TENANT (tenant-scoped like the
|
||||
-- slot engine; tenant-agnostic would leak cross-tenant busy state). This cannot be expressed in the Prisma schema
|
||||
-- (Prisma has no exclusion-constraint primitive), so it stays raw SQL.
|
||||
--
|
||||
-- This is the second layer. The first layer is the application Serializable
|
||||
-- transaction in BookingSubmitService that re-checks slot availability and returns
|
||||
@@ -24,7 +28,7 @@
|
||||
-- -- (leave btree_gist installed; other modules may rely on it)
|
||||
-- =============================================================================
|
||||
|
||||
-- gist over a scalar (providerUserId) + a range (tstzrange) needs the btree_gist
|
||||
-- gist over a scalar (providerUserId) + a range (tsrange) needs the btree_gist
|
||||
-- extension to put the equality column into the same gist index.
|
||||
CREATE EXTENSION IF NOT EXISTS btree_gist;
|
||||
|
||||
@@ -40,8 +44,9 @@ BEGIN
|
||||
ALTER TABLE "Appointment"
|
||||
ADD CONSTRAINT appointment_no_overlap
|
||||
EXCLUDE USING gist (
|
||||
"tenantId" WITH =,
|
||||
"providerUserId" WITH =,
|
||||
tstzrange("startAt", "endAt", ''[)'') WITH &&
|
||||
tsrange("startAt", "endAt", ''[)'') WITH &&
|
||||
)
|
||||
WHERE (status IN (''scheduled'', ''held''))
|
||||
';
|
||||
|
||||
Reference in new issue
Block a user