Migrating a Bubble Booking App: Prevent Double Bookings in Code
A booking migration is not complete when the calendar looks right and existing reservations appear in the new database. The harder question is what happens when two customers try to claim the same remaining capacity at the same time.
When moving a Bubble booking app to code, define the capacity rule, enforce it where reservations are committed, and test competing requests—not just one successful checkout. Keep one authoritative booking writer during the transition. A faster interface or a new database does not, by itself, prevent overselling.
This guide focuses on reservation correctness for appointments, rooms and limited-capacity sessions. It is not a claim that every Bubble booking app has a concurrency defect, or that rewriting a working product is necessary.
Start with a booking contract, not the calendar widget
Write down what a reservation actually consumes. One appointment may require a staff member, a room and a piece of equipment. A class may have twelve interchangeable seats. A rental may occupy several days plus a cleaning buffer. These are different rules, even if all three interfaces show a calendar.
For each booking type, agree on:
The resource or capacity pool, including the organization that owns it.
Which states consume capacity: a temporary hold, confirmed booking, pending approval or something else.
The interval boundaries, buffers and business time zone.
When a hold expires, who may extend it and what happens to late payment.
Whether cancellation immediately releases capacity and how rescheduling works.
Whether staff can override capacity, and what approval and record of the override are required.
Use a concrete example. For an illustrative single-room business, a confirmed booking occupies 10:00–11:00, and the next booking may start at 11:00. A fifteen-minute cleanup rule would change that result. Neither behavior should be inferred from the calendar's appearance.
Compare the contract with current Bubble workflows, backend jobs, plugins and staff practices. Record discrepancies as decisions to resolve, not bugs to copy automatically. Bubble's workflow documentation explains how events drive database changes and external actions; the migration inventory needs to follow those actions beyond the visible booking form.
Separate displayed availability from the right to reserve
A customer can leave a screen open while another customer books its last slot. Refreshing availability improves the experience, but the final reservation request still needs an authoritative decision.
Consider two requests that both read “one seat left,” then each creates a booking. A separate availability check followed by an unprotected write can allow both requests to succeed. Disabling a button helps with accidental repeat clicks; it does not coordinate two browsers, staff actions or API callers.
Ask the developer to identify the operation that both checks and claims capacity, and the rule that makes competing claims safe. Every write path must use that protection, including admin tools and imports that create active bookings.
For a single exclusive resource, a database constraint may fit the rule. PostgreSQL supports exclusion constraints that can reject overlapping ranges for the same resource. Its range documentation also explains inclusive and exclusive endpoints. That is useful for a room or staff member, but it is not a complete design for a class with twelve seats or a booking requiring several resources.
For pooled capacity, the team may use a guarded capacity update or a transaction with a suitable concurrency-control design. Simply wrapping a read and write in a transaction is not enough to establish the intended behavior. PostgreSQL's transaction-isolation documentation describes the guarantees and the need to handle retries when using Serializable isolation. Ask for evidence of the chosen behavior under contention, not just the word “transaction.” Retry the database operation safely; do not repeat an external charge or confirmation message merely because a database transaction is retried.
When a booking needs several resources, claim them together or reject the attempt without leaving a partial reservation. Handle a failed reschedule without releasing the original booking prematurely.
Treat retries, holds and payment as separate problems
Two customers competing for one room is different from one customer's request being retried after a network timeout. The first needs capacity protection; the second needs a stable way to recognize the same booking attempt.
Give a booking attempt an identity that survives retries. The server should reject conflicting reuse of that identity and return the existing result when the same authorized operation is repeated. Scope that identity so another customer cannot use it to retrieve a reservation. Define how long it remains recognizable and what the interface does if the result is temporarily unknown.
Payment-provider idempotency is useful but does not reserve your room. Stripe documents idempotent requests for retrying supported operations without repeating them. Your booking database still needs its own rules, and the payment operation must remain linked to the correct reservation.
Choose the payment sequence deliberately. If the app reserves a temporary hold before payment, specify how capacity is released after expiry and what to do if payment succeeds after that release. Do not automatically confirm a now-unavailable slot. The agreed outcome might be an alternative booking or a refund workflow; it is a product decision, not a generic implementation default.
A database commit and an external payment request are not one atomic operation. Keep enough state to reconcile a timeout or partial failure without asking the customer to pay again blindly. Confirmation messages should reflect the recorded booking outcome, not merely a button click or a returned checkout page.
Move existing reservations without creating a second booking authority
Build an old-to-new mapping for reservation IDs and resources, including active holds, cancellations and reschedules. Reconcile remaining capacity using the agreed states—not only the total number of imported rows. Existing overlaps need an owner and a resolution before a new constraint can be enabled; do not silently delete a reservation to make the import pass.
For date interpretation, use the separate Bubble dates and time zones migration guide. This article's concern is who can claim capacity, rather than how timestamps are represented.
During cutover, avoid letting Bubble and the replacement independently confirm bookings against separate capacity records. Choose a controlled write pause or a shared authoritative reservation service with explicit routing. Include staff screens, backend jobs, integrations and already-open customer tabs in that routing decision.
A rollback also has to account for reservations accepted after the switch. Sending traffic back to an old snapshot can reopen capacity already sold by the new app. The Bubble migration cutover guide covers that broader transition decision.
Ask for a small, adversarial acceptance exercise
Use a test environment with controlled resources and payment-provider test facilities. These are illustrative acceptance cases to adapt to your booking contract, not results from a customer project.
Two different customers submit otherwise valid requests for one available exclusive slot concurrently, with payment outcomes controlled by the test. Exactly one reservation is confirmed; the other receives a clear unavailable outcome.
With one seat left in a capacity pool, several requests compete. Confirmed bookings plus capacity-consuming holds never exceed the limit.
The same booking attempt is submitted again after the first response is lost. The customer gets the same reservation, not a second reservation or payment operation.
A hold expires while a payment result is delayed. The result follows the agreed late-payment policy and does not silently take another customer's slot.
A customer reschedules into an occupied slot. The rejected move preserves the original booking unless the product explicitly specifies otherwise.
A staff member and a customer compete for the same capacity. Both paths follow the same rule, with any permitted override recorded distinctly.
A browser tab opened before cutover submits afterward. Its request reaches the authoritative writer or fails safely; it cannot create an independent legacy confirmation.
Run competing requests with controlled synchronization so they actually overlap, and repeat the cases. Sequentially clicking two buttons does not establish concurrency safety. Inspect database state and payment-provider records as well as screen messages. Save the request identifiers, expected result and observed result so a later regression can be reproduced without retaining unnecessary personal data.
Make the decision about your product
If a booking defect can be corrected within your current architecture, a complete migration may be unnecessary. Compare that fix with the specific constraints driving a rebuild, including ownership and maintenance responsibilities. Custom code gives your team implementation choices; it also makes the team responsible for operating those choices.
Bubble to Code describes its architecture review for technical teams around the data model, workflows, integrations and cutover. For a booking product, bring the capacity contract, representative reservations and the failure cases above to that discussion. They make the scope more concrete than “rebuild the calendar.”
Sources
- 01workflow documentation · Bubble Docs
- 02range documentation · PostgreSQL Docs
- 03transaction-isolation documentation · PostgreSQL Docs
- 04Stripe documents idempotent requests · Stripe Docs
Keep reading
Bubble to Code is an independent service. Not affiliated with, endorsed by, or sponsored by Bubble Group, Inc.
