CLI Usage

Complete guide for using MSR Firebase from the command line.

Use the Realtime Database URL shown in Firebase Console. Its hostname varies by database location; the examples use DATABASE-NAME.REGION.firebasedatabase.app as a placeholder.

Table of contents

  1. Commands
  2. Configuration
  3. Examples
  4. CI/CD Integration
  5. Quick Start
  6. Common Commands
    1. Run Migrations
    2. Check Status
    3. Roll back to a target version
  7. Inherited Commands

Commands

Firebase-specific commands for managing migrations and database operations.

Configuration

CLI flags and options for configuring MSR Firebase behavior.

Examples

Real-world CLI workflows and usage patterns.

CI/CD Integration

Using MSR Firebase CLI in continuous integration and deployment pipelines.


Quick Start

Install and run migrations with a single command:

# Install
npm install @migration-script-runner/firebase

# Run migrations
npx msr-firebase migrate \
  --database-url https://DATABASE-NAME.REGION.firebasedatabase.app \
  --credentials ./serviceAccountKey.json

Common Commands

Run Migrations

# With inline credentials
npx msr-firebase migrate \
  --database-url https://DATABASE-NAME.REGION.firebasedatabase.app \
  --credentials ./serviceAccountKey.json

# With environment variables
export DATABASE_URL=https://DATABASE-NAME.REGION.firebasedatabase.app
export GOOGLE_APPLICATION_CREDENTIALS=./serviceAccountKey.json
npx msr-firebase migrate

Check Status

# List migrations
npx msr-firebase list

# Show Firebase connection info
npx msr-firebase firebase:info

# Test connection
npx msr-firebase firebase:test-connection

Roll back to a target version

down requires a numeric target version and reverses migrations newer than that target:

npx msr-firebase down 202501150001

Inherited Commands

MSR Firebase inherits standard migration commands from MSR Core:

  • migrate - Run pending migrations
  • list - List all migrations with status
  • down - Rollback migrations
  • validate - Validate migration scripts
  • backup - Backup operations
  • lock:status - Check migration lock status
  • lock:release - Force release migration lock

For detailed documentation of the standard commands, see the MSR Core CLI Reference.