-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmigrate.js
34 lines (31 loc) · 898 Bytes
/
migrate.js
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
/**
* This program is used to execute the database migrations.
* It should be run from the build target `migrate`:
* e.g., `yarn migrate`
*/
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Database = require('better-sqlite3-helper');
const dbPath = `${process.cwd()}/prisma/gallformers.sqlite`;
const config = {
path: dbPath,
readonly: false,
fileMustExist: true,
WAL: false,
verbose: true,
migrate: {
force: true,
table: 'migration',
migrationPath: './migrations',
},
};
// hack to force flush migrations. :(
const hack = new Database(config);
hack.run('VACUUM;');
hack.close();
const DB = new Database(config);
console.log(`Initing DB ${JSON.stringify(DB, null, ' ')}`);
DB.close();
} catch (e) {
console.error(e);
}