Migrating from v0.2.x to v1.0.0
A practical guide to upgrading to MSR Firebase v1.0.0.
Table of Contents
- Overview
- Before You Upgrade
- Upgrade the Package
- Core API Names
- Configuration Loading
- Lock Records
- Backup Configuration
- Entity Keys
- Verify the Upgrade
Overview
The v1.0.0 work upgrades the adapter to MSR Core v1 and updates the supported Node.js runtime. The usual Firebase application setup remains familiar: FirebaseRunner.getInstance({ config }) still creates a runner from an explicit FirebaseConfig. The migration steps below focus on runtime support, Core integrations, configuration loading, and lock records.
Before You Upgrade
- Use Node.js
>=22.13.0, as required by the package’senginesfield. The repository’s.nvmrcselects Node 22. - Schedule the upgrade when no migration is running. Review the lock-record change below before rolling out multiple application instances.
- Back up important Firebase data according to your operational procedures.
Upgrade the Package
Update the adapter in your application:
npm install @migration-script-runner/firebase@1.0.0
If your application imports MSR Core directly or declares it as a direct dependency, update that dependency to a compatible Core v1 release as well. The Firebase package uses Core v1 internally.
Core API Names
Most applications that only call FirebaseRunner do not need to rename their code. If your code implements Core adapters or uses these Core symbols directly, update the names:
| MSR Core 0.8.x | MSR Core v1 |
|---|---|
MigrationScriptExecutor |
MigrationScriptRunner |
IExecutorOptions |
IRunnerOptions |
IMigrationExecutorDependencies |
IRunnerDependencies |
createExecutor in a Core CLI adapter |
createRunner |
executorId in locking contracts and lock records |
runnerId |
FirebaseRunner remains the adapter’s public runner class, and its normal factory call remains:
const runner = await FirebaseRunner.getInstance({ config });
Core v1 also provides a standard getInstance() factory contract for adapters. Firebase implements it with Core’s createInstance() helper; application code does not need to implement this factory itself.
Configuration Loading
The behavior of FirebaseRunner.getInstance() changes when config is omitted. Core now resolves configuration before creating the Firebase handler. It uses the supplied configLoader, or Core’s default loader when none is supplied. The same resolved FirebaseConfig is passed to the handler and runner.
// Use Core configuration-file and environment loading.
const runner = await FirebaseRunner.getInstance({});
Passing an explicit config continues to use that object as-is and skips both the default and custom config loaders:
const config = new FirebaseConfig();
config.databaseUrl = process.env.DATABASE_URL;
config.applicationCredentials = process.env.GOOGLE_APPLICATION_CREDENTIALS;
config.folder = './migrations';
const runner = await FirebaseRunner.getInstance({ config });
Choose one approach deliberately. If you expect Core to read configuration from its standard sources, do not pass a manually-created config object. See Library Configuration and FirebaseRunner for the full options.
Service-account credential files
The Firebase Admin connection fix in v1.0.0 does not change the public configuration format. FirebaseConfig.applicationCredentials, GOOGLE_APPLICATION_CREDENTIALS, and the CLI --credentials option still accept a path to a service-account JSON file. The adapter now passes that path to Firebase Admin’s credential loader correctly; no application code change is required for this fix (#108).
Lock Records
The Firebase lock record field changes from executorId to runnerId to match Core v1. An active lock written by v0.2.x still prevents another runner from acquiring the lock, but the new version may not show its owner or release it by owner ID.
Before upgrading a multi-instance deployment, let any running v0.2.x migration finish and release its lock. If a lock remains after the old process has stopped, check its expiry and follow the safe cleanup guidance in Migration Locking; never remove a lock while a migration may still be running.
Backup Configuration
Core v1 continues to own --backup-mode; its existing CLI spelling and values remain available. MSR Firebase adds backupPaths for limiting Core-managed migration backups to selected relative database paths. When unset, backups still cover the full database. The CLI equivalent is --backup-paths:
msr-firebase migrate \
--backup-mode full \
--backup-paths users settings/theme
Paths are resolved beneath the configured shift. Invalid, absolute, empty, duplicate, or overlapping selections are rejected. Restore applies only to the selected paths and leaves data outside them untouched. Review Backup & Restore before enabling this option.
Entity Keys
IEntity.key is now optional. Existing code that supplies a string key is unchanged; code creating entities without a key can omit it instead of passing key: undefined:
import { IEntity } from '@migration-script-runner/firebase';
interface ExampleEntity extends IEntity {
name: string;
}
const entity: ExampleEntity = { name: 'Example' };
Verify the Upgrade
- Update the package and use the supported Node.js version.
-
Run the project’s build, lint, and tests:
npm ci npm run build npm run lint npm test - Run migrations against a Firebase Emulator or a non-production database first.
- Confirm the configured database URL, credentials,
shift, backup behavior, and lock timeout before deploying to production.
For the complete v1.0.0 change history, see the repository CHANGELOG.md.