A CLI tool for managing Firestore schema migrations and data alterations using TypeScript files. v2.1.8 requires Node.js >=21.0.0 and is Pure ESM (package.json must have type:module). Supports migration up/down, rollback, refresh, and custom alter scripts. Runs against Firestore emulator or production projects via Firebase Admin SDK. Ships TypeScript definitions. The tool exports ActionArg types for migration/alter functions.
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ActionArg is not exported from the main entry; must use 'alter-firestore/types/command' subpath.
import { ActionArg } from 'alter-firestore/types/command'
Options types are in the 'types/options' subpath.
import { MigrateOptions } from 'alter-firestore/types/options'
This package is Pure ESM and cannot be used with CommonJS require(). Package.json must contain 'type': 'module'.
import ... from 'alter-firestore'
Setup and create a basic migration file that creates a document (up) and deletes it (down), then run against the Firestore emulator.
// Set package.json type to module
// package.json: { "type": "module" }
// Install
// npm i alter-firestore
// Install ts-node for TypeScript execution
// npm i -D ts-node
// Create .alfsrc.js
export default {
emulator: {
options: { projectId: 'demo-project' },
ports: { firestore: '8080' },
},
credentialPaths: { staging: './staging-key.json' },
migrations: { collectionName: 'migrations', directoryPath: 'migrations' },
};
// Create a migration file: migrations/001_create_users.ts
import { ActionArg } from 'alter-firestore/types/command';
import { MigrateOptions } from 'alter-firestore/types/options';
export const up = async ({ firestore }: ActionArg<MigrateOptions>) => {
return firestore.create('users', 'user1', { name: 'Alice' });
};
export const down = async ({ firestore }: ActionArg<MigrateOptions>) => {
const ref = firestore.doc('users/user1');
return firestore.recursiveDelete('users', ref);
};
// Run migration against emulator
// npm run alfs -- migrate
// or: node --loader ts-node/esm node_modules/.bin/alfs migrate
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.