@js-migrations/core

Provides a common service for migrations in JavaScript.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@js-migrations/core
2276.2.36 years ago6 years agoMinified + gzip package size for @js-migrations/core in KB

Readme

core
Provides a common service for migrations in JavaScript.

Usage

  1. Install it with npm i @js-migrations/core.
  2. Create a repository facade.
  3. 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.