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
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 migrationslist- List all migrations with statusdown- Rollback migrationsvalidate- Validate migration scriptsbackup- Backup operationslock:status- Check migration lock statuslock:release- Force release migration lock
For detailed documentation of the standard commands, see the MSR Core CLI Reference.