umzug-typescript-helper
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

Build Status

umzug-typescript-helper

A micro library helping using TypeScript in your umzug migrations.

Why?

umzug may run JS scripts only. Thus, in order to run a TypeScript migration you will have to compile all the migrations before umzug may run this.

This little library makes things a bit easier. All you need is just 1 TypeScript file that acts as an entry point for your migration. Something like this:

import * as migrations from './migrations';
import { migrate } from 'umzug-typescript-helper';

const umzugOptions = {
    // your umzug config, see https://github.com/sequelize/umzug for more info
};

migrate(migrations, umzugOptions).catch((err: any) => {
    console.error(err);
    process.exit(1);
});

And then your migrations go like this (e.g. in src/migrations/index.ts):

export function _20180902_initial() {
    return Promise.resolve("The migration ran successfully!");
}

Then you just compile (or/and bundle) everything and just run the migrations entrypoint script.

See this link for the complete example.

Check out this article for more details: How to migrate DBs with NodeJS and TypeScript

Package Sidebar

Install

npm i umzug-typescript-helper

Weekly Downloads

4

Version

1.0.10

License

Unlicense

Unpacked Size

8.5 kB

Total Files

6

Last publish

Collaborators

  • bleshik