## Apply Database Schema Changes for Next.js

### Summary
Schema changes for a Next.js app on Ample. Verified on Next.js: a --release-command migration ran before activation and its marker was readable by the live app (migrated=release-ok). Build and start: `next build` then `next start -H 0.0.0.0 -p $PORT` on the node-22 template.

### Requirements
- **Resource Requirements:**
  - Compute
  - Postgres

- **Infrastructure Requirements:**
  - **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request.
  - **Postgres**: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when needed.

### Prerequisites
- A Next.js project (`next build` then `next start -H 0.0.0.0 -p $PORT` on the node-22 template)
- A PostgreSQL driver reading DATABASE_URL at runtime
- An Ample account token with servers:write, databases:read

### Workflow Steps
1. **Build and Start**:
   - `next build` then `next start -H 0.0.0.0 -p $PORT` on the node-22 template; the server must bind 0.0.0.0 on PORT.

2. **Run Migrations as the Release Command**:
   - Ample runs the command before activation and fails if it exits non-zero; keep migrations idempotent.
   - Command: `ample deploy . --name <app_name> --public --release-command "node migrate.cjs"`

3. **Verify**:
   - Fetch the live URL and `/p/migrated` on the example; on failure read the build and runtime logs.
   - Command: `ample logs <app_name> --kind build`

### Success Checks
- App responds on its public URL (Expect: `ample canary next js patterns`)
- Migrated check from the example (Expect: `see the pattern fixture checks`)

### Limitations
- Verified on the node-22 template at s-1vcpu-1gb; other sizes and Next.js major versions are not verified.
- Region, compliance attestations, and request-duration limits are unknown.

### Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Components**:
  - App server (size: s-1vcpu-1gb, quantity: 1.0, monthly amount: 5.0)
  - Managed PostgreSQL database (size: s-1vcpu-1gb, quantity: 1.0, monthly amount: 5.0)  
- **Note**: Always-on monthly price of the tested sizes; apps auto-pause when idle.

### Examples
- **Next.js Pattern Fixture**: Verified schema changes on Next.js. Source: tests/deploy-canaries/next-js-patterns

### Evidence Summary
- Next.js pattern fixture deployed on Ample (next build then next start -H 0.0.0.0 -p $PORT on the node-22 template); for this guide: a --release-command migration ran before activation.

### Last Verified At
- 2026-09-21T02:34:39Z

### Next Actions
- [Browse the catalog index](https://api.ample.computer/v1/catalog)
- [Search published recipes by intent](https://api.ample.computer/v1/catalog/search)
- [Prepare a side-effect-free deployment plan](https://api.ample.computer/v1/catalog/plan)
