1. MooseStack
  2. Moose Migrate
  3. moose prod

On this page

OverviewCommand ReferenceExecution LifecycleFailure ModesSee Also

moose prod

The Moose Runtime deployment model (invoked via moose prod) includes an automatic migration runner that executes planned changes during the application boot sequence.

Overview

When running as a full server, Moose orchestrates the entire lifecycle of your data stack. Migrations are treated as a prerequisite for starting the application: the server will not accept traffic or process data until the database schema matches the code definition.

FeatureDescription
Automatic ExecutionMigrations run automatically when the moose prod command starts.
Drift ProtectionThe server validates the database state against remote_state.json before applying changes.
Code ValidationThe server ensures the deployed code matches local_infra_map.json to prevent mismatches.
Zero-TouchNo separate CLI commands or CI/CD steps are required to apply migrations.

Command Reference

The migration logic is embedded within the production server start command.

moose prod

Environment Variables: The server requires access to the ClickHouse database, typically configured via moose.config.toml or environment variables overridden at runtime.

Execution Lifecycle

When moose prod starts, it performs the following sequence:

  1. Load Plan: Reads migrations/plan.yaml from the deployment artifact.
  2. Check Code Consistency: Verifies that the running application code matches . If not, it aborts to prevent deploying code that doesn't match the plan.
local_infra_map.json
  • Check Database Drift: Connects to ClickHouse and compares the current schema against remote_state.json. If drift is detected, it aborts.
  • Execute Migration: Applies the operations defined in plan.yaml.
  • Start Services: Once migrations succeed, the Ingestion API, Consumption API, and Streaming workers are started.
  • Failure Modes

    ConditionOutcomeResolution
    Drift DetectedServer fails to start.Regenerate the plan against the current production DB and redeploy.
    Plan MismatchServer fails to start.Ensure the migrations/ directory matches the code in your deployment artifact.
    Migration ErrorServer fails to start.Fix the schema issue or plan file, then redeploy.
    Boreal Hosting

    If you are using Boreal Hosting, this process is handled automatically. The platform ensures that your application only becomes healthy once moose prod has successfully completed the migration phase.

    See Also

    • Planned Migrations — Generate the migration plan files
    • moose migrate — Manual CLI migrations for serverless deployments
    FiveonefourFiveonefour
    Fiveonefour Docs
    MooseStackTemplates
    Changelog
    Source506
    • Overview
    • Quick Start
    • Templates / Examples
    Fundamentals
    • Moose Runtime
    • MooseDev MCP
    • Data Modeling
    MooseStack in your App
    • App / API frameworks
    Modules
    • Moose OLAP
    • Moose Streaming
    • Moose Workflows
    • Moose APIs
    Deployment & Lifecycle
    • Moose Migrate
      • Migration Modes
      • Automatic Migrations
      • Planned Migrations
      • Plan Reference
      • Executing Migrations
      • moose migrate (CLI)
      • moose prod (Runtime)
      • Lifecycle Management
      • Fully Managed
      • Deletion Protected
      • Externally Managed
      • Advanced Topics
      • Failed Migrations
    • Moose Deploy
    Reference
    • API Reference
    • Data Types
    • Table Engines
    • CLI
    • Configuration
    • Observability Metrics
    • Help
    • Changelog
    Contribution
    • Documentation
    • Framework