1. MooseStack
  2. Moose Migrate
  3. moose migrate

On this page

OverviewCommand ReferenceOptionsExecution LifecycleFailure ModesCI/CD ExampleSee Also

moose migrate

The CLI deployment model relies on the moose migrate CLI command to execute planned schema changes. This gives you explicit control over when migrations run, which is essential for architectures where Moose OLAP is integrated as a library rather than a standalone server (e.g. as a library in a Python or TypeScript application).

Overview

In serverless or library-based deployments, MooseStack does not control the application runtime. Therefore, migrations must be triggered externally, typically as a step in a CI/CD pipeline or a manual administrative action.

FeatureDescription
Manual ControlMigrations run only when you explicitly execute the command.
CI/CD IntegrationDesigned to run as a discrete step in deployment pipelines (e.g., GitHub Actions).
Drift ProtectionValidates remote_state.json against the target database before execution.
Direct ConnectionConnects directly to ClickHouse using a connection string.

Command Reference

moose migrate --clickhouse-url <CONNECTION_STRING>

Options

OptionDescriptionRequired
--clickhouse-urlThe full connection string to the target ClickHouse database (e.g., clickhouse://user:pass@host:9440/db).Yes

Execution Lifecycle

When moose migrate is executed:

  1. Load Plan: Reads migrations/plan.yaml from the current directory.
  • Check Database Drift: Connects to the provided ClickHouse URL and compares the current schema against remote_state.json.
  • Abort on Drift: If the database state does not match the snapshot, the process exits with an error code.
  • Execute Migration: Applies the operations defined in plan.yaml sequentially.
  • Report Success: Exits with code 0 if all operations succeed.
  • Failure Modes

    ConditionOutcomeResolution
    Drift DetectedCommand fails (exit code 1).Regenerate the plan against the current production DB and retry.
    Connection ErrorCommand fails (exit code 1).Check network connectivity and credentials in the connection string.
    SQL ErrorCommand fails (exit code 1).Fix the problematic operation in plan.yaml or the database state and retry.

    CI/CD Example

    This command is typically used in a deployment pipeline before updating the application code.

    # Example GitHub Actions step- name: Apply Migrations  run: moose migrate --clickhouse-url "$CLICKHOUSE_URL"        env:    CLICKHOUSE_URL: ${{ secrets.CLICKHOUSE_URL }}

    See Also

    • Planned Migrations — Generating the plan files
    • moose prod (Moose Runtime Migrations) — Automatic migrations for Moose Runtime deployments
    • Migration Modes — Overview of schema evolution modes
    • 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
    FiveonefourFiveonefour
    Fiveonefour Docs
    MooseStackTemplates
    Changelog
    Source506