Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compute/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Composer.
| [`nextjs`](./nextjs) | Next.js App Router app using standalone output for Prisma Compute. |
| [`tanstack-start`](./tanstack-start) | TanStack Start app using the Nitro Vite plugin output supported by Prisma Compute. |
| [`personal-site`](./personal-site) | Astro personal site with no database. |
| [`room-booking-prisma-template`](./room-booking-prisma-template) | Next.js room booking app: Resource Scheduler timeline, row locks and an exclusion constraint against double booking. |

Each example includes a Composer module and a GitHub Actions deployment
workflow. The database-backed examples also include a Prisma 8 contract,
Expand Down
14 changes: 14 additions & 0 deletions compute/room-booking-prisma-template/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Local settings for `npm run dev`, the db:* scripts and the tests.
# Copy this file to .env.local (not .env: `next build` copies .env into the
# bundle that `npm run deploy` uploads) and fill in your own values.
#
# Not needed for `npm run dev:composer`, which starts its own local database,
# or on Prisma Compute, where the app gets its database from Composer.

# Any PostgreSQL 15+ database. For a free temporary Prisma Postgres database,
# run `npx create-db@latest` and paste the connection string it prints.
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/rooms"

# Optional: a separate, disposable database for the integration tests
# (`npm test`). They delete its data. Use a real PostgreSQL server here.
# TEST_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/rooms_test"
6 changes: 6 additions & 0 deletions compute/room-booking-prisma-template/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/prisma/contract.json linguist-generated
src/prisma/contract.d.ts linguist-generated
src/prisma/ops.json linguist-generated
src/prisma/migration.json linguist-generated
migrations/snapshots/**/contract.json linguist-generated
migrations/snapshots/**/contract.d.ts linguist-generated
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: prisma-deploy

on:
push:
delete:

concurrency:
group: prisma-deploy-${{ github.event_name == 'delete' && github.event.ref || github.ref_name }}
cancel-in-progress: false

permissions:
contents: read
id-token: write
pull-requests: write

jobs:
deploy:
if: github.event_name == 'push' && github.ref_type == 'branch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.4.0
- uses: oven-sh/setup-bun@v2.2.0
- uses: actions/setup-node@v4.4.0
with:
node-version-file: .nvmrc
- uses: prisma/cloud-deploy-action@v1.6.0

teardown:
if: github.event_name == 'delete' && github.event.ref_type == 'branch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.4.0
- uses: oven-sh/setup-bun@v2.2.0
- uses: actions/setup-node@v4.4.0
with:
node-version-file: .nvmrc
- uses: prisma/cloud-deploy-action@v1.6.0
with:
mode: destroy
stage: ${{ github.event.ref }}
35 changes: 35 additions & 0 deletions compute/room-booking-prisma-template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# dependencies
node_modules/

# Next.js
/.next/
/out/
next-env.d.ts
*.tsbuildinfo

# build output
dist/
/build/
/coverage/

# env files: commit .env.example only
.env
.env*.local

# Prisma Composer and its deploy engine
/.alchemy
/.prisma-composer
/.prisma

# misc
.DS_Store
*.pem
npm-debug.log*

# local AI assistant files
.claude/
CLAUDE.md
CLAUDE.local.md

# local browser-automation output
.playwright-mcp/
1 change: 1 addition & 0 deletions compute/room-booking-prisma-template/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
21 changes: 21 additions & 0 deletions compute/room-booking-prisma-template/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- BEGIN:nextjs-agent-rules -->

## This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices.

This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.

<!-- END:nextjs-agent-rules -->

## This project

A room booking template: Next.js 16 App Router, Resource Scheduler (from npm), Prisma ORM 8, Prisma Postgres, Prisma Compute via Prisma Composer. See README.md.

- Node.js 24 (`.nvmrc`), the version the template is tested on; the Prisma CLI needs 22.18+. Bun must be installed for `npm run dev:composer`, and it does not run on Windows (`prisma dev` returns `DEV.PLATFORM_UNSUPPORTED`): use macOS, Linux, WSL or a Linux container. `prisma dev` runs in the foreground (Ctrl+C stops it); there is no `prisma dev stop`.
- Deploy is `npm run deploy` (`next build`, then `prisma deploy module.ts`). There is no `prisma.compute.ts`, `defineComputeConfig` or `compute:deploy`: that flow was removed. Do not add them. A deploy without `--stage` is production; ask first. `npx prisma auth login` needs a person at a browser.
- Booking rules live in one place, `src/lib/rules.ts`, used by the browser (`<ResourceScheduler {...}>`) and the server (`isPlacementAllowed` in `src/server/bookings.ts`). Keep them independent of the machine's time zone (`utcToZoned(date, OFFICE_TIME_ZONE)`).
- Every booking write locks the room row(s) inside `db.transaction` before checking; keep the lock order (booking, then rooms sorted by id). Prisma ORM 8 has no isolation-level option.
- Schema changes: edit `src/prisma/contract.prisma`, `npm run contract:emit`, `npm run migration:plan -- --name <name>`, `npm run db:migrate`. Never hand-edit `ops.json`; edit `migration.ts` and run it with `node` to recompile.
- Local settings go in `.env.local`, never `.env` (`next build` copies `.env` into the deployed bundle).
- Before committing: `npm run lint`, `npm run typecheck`, `npm test` (with `TEST_DATABASE_URL` for the PostgreSQL tests), `npm run build`.
21 changes: 21 additions & 0 deletions compute/room-booking-prisma-template/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Mohammed Obaid

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading