-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathumzug.ts
26 lines (21 loc) · 856 Bytes
/
umzug.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import "tsconfig-paths/register";
import 'dotenv/config';
import { Sequelize } from "sequelize";
import { Umzug, SequelizeStorage } from "umzug";
import {connectionParams} from "./src/db/database";
const sequelize = new Sequelize(connectionParams);
console.info("DB connection params: ", connectionParams);
const umzug = new Umzug({
migrations: { glob: "migrations/*.ts" },
context: sequelize.getQueryInterface(),
storage: new SequelizeStorage({ sequelize }),
logger: console,
});
(async () => {
// Checks migrations and run them if they are not already applied. To keep
// track of the executed migrations, a table (and sequelize model) called SequelizeMeta
// will be automatically created (if it doesn't exist already) and parsed.
await umzug.up();
})();
export type Migration = typeof umzug._types.migration;
export { sequelize };