Tiny helper library for migrating data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Bauke b798e18a16
Version 0.1.3!
2 months ago
source Make the default skip use <= instead. 9 months ago
tests Initial 0.1.0 commit! 🎉 9 months ago
.gitignore Initial 0.1.0 commit! 🎉 9 months ago
LICENSE Relicense to AGPL-3.0-or-later. 2 months ago
README.md Rewrite readme. 2 months ago
package.json Version 0.1.3! 2 months ago
pnpm-lock.yaml Update dependencies. 2 months ago
tsconfig.json Initial 0.1.0 commit! 🎉 9 months ago

README.md

Migration 🧳 Helper

Tiny helper library for migrating data.

Features

  • Zero dependencies.
  • 100% code coverage.
  • TypeScript definitions included.

Registry Setup

To use this package, add a registry for the @holllo scope to your npm configuration.

npm config set @holllo:registry https://git.bauke.xyz/api/packages/Holllo/npm/

Usage

import {migrate, Migration} from '@holllo/migration-helper';

// Your data that needs migrating.
const data = 'data';

// Your data's current version.
const version = '1.0.0';

// Create some migrations to apply.
const migrations: Array<Migration<string>> = [
  {
    version: '1.0.1',
    migrate: async (data: string) => `${data} migrated`,
  },
  {
    version: '1.0.2',
    migrate: async (data: string) => `${data} (again!)`,
  },
];

// Migrate your data.
const migrated = await migrate(data, version, migrations);

// Congratulations, your data is now on version 1.0.2!
console.log(migrated);

See the tests directory for how to use number, Date or a custom way of versioning.

License

Distributed under the AGPL-3.0-or-later license, see LICENSE for more information.