@js-migrations/core
v6.2.3
Published
Provides a common service for migrations in JavaScript.
Downloads
28
Readme
core
Provides a common service for migrations in JavaScript.
Usage
- Install it with
npm i @js-migrations/core
. - Create a repository facade.
- Use the factory to create the service facade.
Create a repository facade
This package contains the RepoFacade TypeScript interface. You can create a facade to match the interface using the factories below.
Use the factory
import migrationsServiceFactory from '@js-migrations/core/dist/factory';
const migrationsServiceFacade = migrationsServiceFactory({
repo: migrationsRepoFacade,
});
Intentions
- Create an API for processing migrations in applications storing data in multiple ways (e.g. databases and files).
- Allow processed migrations to be recorded in a common format across databases.
- Focus on functions rather than files to improve type checking and composability.
- Focus on migrations being a function of the application rather than just a developer tool.
Avoiding downtime
To avoid downtime caused by deleting columns in migrations it's recommended that you make two releases as explained below where the code changes are deployed before the migrations are processed.
- Initial release
- Code change: Stop reading deleted columns.
- Migration: Make columns to be deleted optional (if not already).
- Final release
- Code change: Stop writing to deleted columns.
- Migration: Delete the columns.