page:guides:express:schema changes

Apply Database Schema Changes for Express

Summary

Apply database schema changes for an Express app on Ample with a release command. The command runs against the injected DATABASE_URL before the new release goes live, and the release fails instead of activating if the migration fails.

Representative Queries

Resource Requirements

Infrastructure Requirements

Framework

Express

Workload

Apply database schema changes

Release Status

Published

Support Status

Verified

Execution Status

Ready

Prerequisites

Tested Configuration

Input Schema

{
  "additionalProperties": false,
  "properties": {
    "env": {
      "description": "Encrypted environment variables as KEY=value; secret values are never stored in ample.toml",
      "items": {"pattern": "^[A-Z][A-Z0-9_]*=.*$", "type": "string"},
      "maxItems": 50,
      "type": "array"
    },
    "name": {
      "description": "App name (lowercase, digits and dashes)",
      "maxLength": 63,
      "minLength": 1,
      "pattern": "^[a-z0-9-]+$",
      "type": "string"
    },
    "path": {
      "description": "Project directory to deploy, or one service name from ample.toml",
      "maxLength": 512,
      "minLength": 1,
      "type": "string"
    },
    "release_command": {
      "description": "One-off command run before the release goes live, for example a migration",
      "maxLength": 512,
      "minLength": 1,
      "type": "string"
    },
    "size": {
      "description": "VM size; omit to let Ample pick a runtime-safe size",
      "enum": ["s-1vcpu-256mb", "s-1vcpu-1gb", "s-1vcpu-2gb", "s-2vcpu-2gb", "s-2vcpu-4gb"],
      "type": "string"
    }
  },
  "required": ["name", "path", "release_command"],
  "type": "object"
}

Workflow Steps

  1. Write an Idempotent Migration: Create tables and markers with IF NOT EXISTS or a migration tool so a re-run is safe.
  2. Deploy with the Release Command: Ample runs the command before activation; a non-zero exit fails the release.
    ample deploy . --name  --public --release-command "node migrate.js"
    
  3. Verify the Marker through the App: Serve a route that reads something only the migration creates.
  4. Verify: Fetch the live URL and run the success checks below. On failure read the build log, then the runtime log, fix the cause and deploy again; do not blind-retry.
    ample logs  --kind build
    

Examples

Success Checks

Limitations

Cost Estimate

Evidence Summary

Last Verified At

2026-09-19T23:55:33Z

Formats