1
Fork 0
migration-helper/README.md

46 lines
1.1 KiB
Markdown

# Migration 🧳 Helper
> **Tiny helper library for migrating data.**
## Features
* Zero dependencies.
* 100% code coverage.
* TypeScript definitions included.
## Usage
```ts
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](https://git.bauke.xyz/Holllo/migration-helper/src/branch/main/tests) for how to use `number`, `Date` or a custom way of versioning.
## License
Distributed under the [AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later.html) license, see [LICENSE](https://git.bauke.xyz/Holllo/migration-helper/src/branch/main/LICENSE) for more information.