1
Fork 0
Tiny helper library for migrating data.
Go to file
Bauke 90ef75b68b
Update dependencies.
2022-09-29 14:26:13 +02:00
source Make the default skip use <= instead. 2022-03-03 22:17:04 +01:00
tests Initial 0.1.0 commit! 🎉 2022-03-03 14:41:55 +01:00
.gitignore Initial 0.1.0 commit! 🎉 2022-03-03 14:41:55 +01:00
LICENSE Relicense to AGPL-3.0-or-later. 2022-09-29 14:25:55 +02:00
README.md Correctly await things. 2022-03-03 15:01:06 +01:00
package.json Update dependencies. 2022-09-29 14:26:13 +02:00
pnpm-lock.yaml Update dependencies. 2022-09-29 14:26:13 +02:00
tsconfig.json Initial 0.1.0 commit! 🎉 2022-03-03 14:41:55 +01:00

README.md

migration-helper

A tiny helper library for migrating data.

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

Usage

npm install migration-helper
import {migrate, Migration} from '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.