1
Fork 0
Tiny helper library for migrating data.
Go to file
Bauke 453b707b46
Add trash-cli.
2024-01-24 19:06:56 +01:00
source Add A and B types to Migration. 2023-05-08 12:24:58 +02:00
tests Update dependencies and fix linting issues. 2024-01-24 19:00:09 +01:00
.envrc Add Nix flake and direnv files. 2024-01-24 19:03:06 +01:00
.gitignore Add Nix flake and direnv files. 2024-01-24 19:03:06 +01:00
LICENSE Relicense to AGPL-3.0-or-later. 2022-09-29 14:25:55 +02:00
README.md Remove custom registry instructions. 2023-05-08 12:25:57 +02:00
flake.nix Add Nix flake and direnv files. 2024-01-24 19:03:06 +01:00
package.json Add trash-cli. 2024-01-24 19:06:56 +01:00
pnpm-lock.yaml Add trash-cli. 2024-01-24 19:06:56 +01:00
shell.nix Add Nix flake and direnv files. 2024-01-24 19:03:06 +01:00
tsconfig.json Initial 0.1.0 commit! 🎉 2022-03-03 14:41:55 +01:00

README.md

Migration 🧳 Helper

Tiny helper library for migrating data.

Features

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

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.