forked from EvoEsports/minicontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.ts
38 lines (34 loc) · 1022 Bytes
/
migrate.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
27
28
29
30
31
32
33
34
35
36
37
38
import { Umzug, SequelizeStorage } from 'umzug';
import { Sequelize } from 'sequelize';
import log from './core/log';
const sequelize = new Sequelize(process.env['DATABASE'] ?? "", {
logging(sql, timing) {
log.info("$d7c" + sql);
},
});
export const migrator = new Umzug({
migrations: {
glob: ['core/migrations/*.ts', { cwd: process.cwd() }],
},
context: sequelize,
storage: new SequelizeStorage({
sequelize,
}),
logger: {
debug: (message) => { },
error: (message) => { log.info("$f00" + message) },
warn: (message) => { log.info("$fa0" + message) },
info: (message) => { log.info("$5bf" + message.event + " $fff" + message.name) },
}
});
export type Migration = typeof migrator._types.migration;
(async () => {
try {
log.info("$fffMigrating:")
await migrator.up()
log.info("$fffMigrating ends!");
process.exit(0);
} catch (e: any) {
log.error("$f00error occurred");
}
})();