### Apply database schema changes for NestJS

Schema changes for a NestJS app on Ample. Verified on NestJS: a --release-command migration ran before activation and its marker was readable by the live app (migrated=release-ok). Build and start: `npm install`, `nest build` (TypeScript) then `node dist/main.js` on the node-22 template.

---

#### Representative Queries
- Apply database schema changes for NestJS
- Where can I host Apply database schema changes built with NestJS?
- I need a framework-specific schema migration and rollback procedure; no managed migration service is assumed.

---

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

---

### Workflow Steps
1. **Build and start**  
   `npm install`, `nest build` (TypeScript) then `node dist/main.js` 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 the release if it exits non-zero; keep migrations idempotent.  
   Command: `ample deploy . --name <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_id> --kind build`

---

#### Prerequisites
- A NestJS project (`npm install`, `nest build` (TypeScript) then `node dist/main.js` on the node-22 template)
- A PostgreSQL driver reading `DATABASE_URL` at runtime
- An Ample account token with `servers:write`, `databases:read`

---

#### Limitations
- Verified on the node-22 template at s-1vcpu-1gb; other sizes and NestJS major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- Managed PostgreSQL 16 only; extensions, connection limits and backup or restore procedures are not verified.

---

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

---

#### Success Checks
- App responds on its public URL  
  **Kind:** http_get  
  **Path:** `/`  
  **Expect:** `ample canary nestjs patterns`
- Migrated check from the example  
  **Kind:** http_get  
  **Path:** `/p/migrated`  
  **Expect:** see the pattern fixture checks

---

### Examples
- **NestJS pattern fixture**  
  Verified schema changes on NestJS.  
  **Source Ref:** `tests/deploy-canaries/nestjs-patterns`

---

### Evidence Summary
- **Kind:** canary_run  
  **Summary:** NestJS pattern fixture deployed on Ample (npm install, nest build (TypeScript) then node dist/main.js on the node-22 template); for this guide: a --release-command migration ran before activation and its marker was readable by the live app (migrated=release-ok).  
  **Observed At:** 2026-09-21T02:34:39Z  
  **Scope:** {checks: [`/p/migrated`], template: `node-22`}
