@js-migrations/core

Provides a common service for migrations in JavaScript.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
226Jun 15, 2021Dec 31, 2017Minified + 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.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.