## Apply Database Schema Changes for Phoenix

### Summary
Schema changes for a Phoenix app on Ample. Verified on Phoenix: a --release-command migration ran before activation and its marker was readable by the live app (migrated=release-ok). Build and start: `mix deps.get`, `MIX_ENV=prod mix compile` and `mix release` in the builder, then the release bin script with `PHX_SERVER=true` on the elixir-1.18 template; `PORT`, `DATABASE_URL` and `SECRET_KEY_BASE` read in `config/runtime.exs`.

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

### Resource Requirements
- Compute
- Postgres

### Infrastructure Requirements
1. **Compute**  
   - **Status**: verified  
   - **Summary**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.

2. **Postgres**  
   - **Status**: verified  
   - **Summary**: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.

### Prerequisites
- A Phoenix project (`mix deps.get`, `MIX_ENV=prod mix compile` and `mix release` in the builder, then the release bin script with `PHX_SERVER=true` on the elixir-1.18 template; `PORT`, `DATABASE_URL` and `SECRET_KEY_BASE` read in `config/runtime.exs`).
- A PostgreSQL driver reading DATABASE_URL at runtime.
- An Ample account token with `servers:write`, `databases:read`.

### Workflow Steps
1. **Build and Start**  
   - `mix deps.get`, `MIX_ENV=prod mix compile and mix release` in the builder, then the release bin script with `PHX_SERVER=true` on the elixir-1.18 template; `PORT`, `DATABASE_URL` and `SECRET_KEY_BASE` read in `config/runtime.exs`.

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  --public --release-command "python3 migrate.py"`

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

### Examples
- **Phoenix Pattern Fixture**  
  Verified schema changes on Phoenix.

### Success Checks
1. **App Responds on Its Public URL**
   - **Kind**: http_get  
   - **Path**: `/`  
   - **Expect**: ample canary phoenix patterns

2. **Migrated Check from the Example**  
   - **Kind**: http_get  
   - **Path**: `/p/migrated`  
   - **Expect**: see the pattern fixture checks

### Limitations
- Verified on the elixir-1.18 template at s-1vcpu-1gb; other sizes and Phoenix 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  
- **Basis**: size prices from pricing.toml (loaded by the API) at build revision 1ac5595375130d45290090e82ed0f554ccd45405-dirty.
- **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. Buckets are allocation-priced per quota and not included.

### Evidence Summary
- **Kind**: canary_run  
  **Summary**: Phoenix pattern fixture deployed on Ample.  
  **Observed At**: 2026-09-20T23:45:31Z  
  **Implementation Revision**: 4d1511e574302f3904b75088bd4048a0975218b3-dirty (CLI 0.1.21)  
  **Expires At**: 2027-03-19T23:45:31Z

### Next Actions
1. **Browse the Catalog Index**  
   - **Action ID**: browse-catalog  
   - **Method**: GET  
   - **Relative Path**: /v1/catalog

2. **Search Published Recipes by Intent, Stack and Constraints**  
   - **Action ID**: search-recipes  
   - **Method**: POST  
   - **Relative Path**: /v1/catalog/search   
   - **Parameters**: `{ "body": { "limit": 5, "query": "Apply database schema changes for Phoenix" } }`

3. **Prepare a Side-Effect-Free Deployment Plan**  
   - **Action ID**: plan:page:guides:phoenix:schema-changes  
   - **Method**: POST  
   - **Relative Path**: /v1/catalog/plan  
   - **Parameters**: `{ "body": { "inputs": {}, "projectId": "", "recipeId": "page:guides:phoenix:schema-changes", "recipeRevision": "r1" } }`

4. **Read the Existing Agent Authentication Setup**  
   - **Action ID**: auth-setup  
   - **Method**: GET  
   - **Relative Path**: /mcp/setup

5. **Browse Phoenix**  
   - **Action ID**: browse:stack:framework-phoenix  
   - **Method**: GET  
   - **Relative Path**: /v1/catalog/nodes/stack%3Aframework-phoenix
