Registry / database / loopback4-migration

loopback4-migration

JSON →
library1.3.0jsnpmunverified

LoopBack 4 component for managing database migration tasks with versioning. Current stable version is 1.3.0, released under MIT license. It provides a common interface for custom migration scripts, automatically discovers and executes migrations based on application version from package.json, and supports both upgrades and downgrades. Key differentiators: integrates seamlessly with LoopBack 4 BootMixin and RepositoryMixin, uses peer dependencies from @loopback ecosystem, and offers automatic script discovery via naming convention or decorators. Release cadence is not specified.

npm install loopback4-migration
INSTALL
IMPORT
SIG · LOOPBACK4-MIGRATIO
L
loopback4-migration
databasejavascriptv1.3.0
harness data pending
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.

MigrationComponent
import { MigrationComponent } from 'loopback4-migration'
const MigrationComponent = require('loopback4-migration')
ESM-only package; requires TypeScript or ESM setup.
MigrationScript
import { MigrationScript } from 'loopback4-migration'
Interface for implementing custom migration scripts.
@migrationScript
import { migrationScript } from 'loopback4-migration'
import { MigrationScript } from 'loopback4-migration'
Decorator is lowercased 'migrationScript'.

Shows how to set up a LoopBack 4 application with BootMixin, RepositoryMixin, and MigrationComponent.

import { ApplicationConfig, BootMixin } from '@loopback/boot'; import { RepositoryMixin } from '@loopback/repository'; import { RestApplication, RestServer } from '@loopback/rest'; import { MigrationComponent } from 'loopback4-migration'; class MyApp extends BootMixin(RepositoryMixin(RestApplication)) { constructor(options?: ApplicationConfig) { super(options); this.component(MigrationComponent); } } export async function main() { const app = new MyApp(); await app.boot(); await app.start(); } if (require.main === module) { main().catch(err => { console.error('Cannot start the application.', err); process.exit(1); }); }
Debug
Known issues
gotchaMigration scripts must have unique class names; duplicates are discarded silently.
fix
Ensure each script class name is unique.
affects: *
gotchaDowngrade is considered an edge case; not all upgrades are reversible.
fix
Implement down() method only if technically possible and always back up the database before upgrades.
affects: *
deprecatedPackage uses legacy LoopBack 4 conventions; may not be compatible with newer LoopBack 4 versions.
fix
Check LoopBack 4 changelog for migration guidance.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module '@loopback/boot'
Peer dependency @loopback/boot is not installed.
fix
Run npm install @loopback/boot
TypeError: app.component is not a function
Component method not available without BootMixin.
fix
Ensure application class extends BootMixin(RepositoryMixin(RestApplication))
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
@loopback/bootrequiredRequired for automatic discovery of migration scripts and application version
@loopback/contextrequiredCore context and dependency injection
@loopback/corerequiredCore LoopBack 4 framework
@loopback/repositoryrequiredRepository mixin and database access
Agent activity
7 hits · last 30 days
node
6
Resources
loopback4-migration — npm install loopback4-migration · libregistry