Skip to content

G0maa/typeorm-storage-umzug

Repository files navigation

TypeORMStorage for Umzug

  • Use Umzug and TypeORM for database migrations using TypeORMStorage, instead of SequelizeStorage.
  • Heavily inspired by SequelizeStorage, I mostly mirrored it to TypeORM (with less features 😬).

How to use?

  • This snippet is from the example.
  1. Install dependencies using yarn add typeorm-storage-umzug or npm install typeorm-storage-umzug.
import { Umzug } from 'umzug';
import { TypeORMStorage } from 'typeorm-storage-umzug';
import { DataSource } from 'typeorm';

const orm = new DataSource({
  type: 'postgres',
  /* remaining DataSource options ... */
});


export const migrator = new Umzug({
  /* ... remaining Umzug options ... */
  context: orm,
  storage: new TypeORMStorage({
    dataSource: orm,
    tableName: 'migrator_meta',
  }),
});
export type Migration = typeof migrator._types.migration;

TODOs

  1. get rid of many .initalize .destroy.
  2. make package not depend on TypeORM or Umzug.
  3. revise .tsconfig I copied the one at nestjs.

About

Umzug's SequlizeStorage but for TypeORM.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published