mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
31 lines
755 B
TypeScript
31 lines
755 B
TypeScript
|
import { log } from 'db-migrate-shared';
|
||
|
import { getInstance } from 'db-migrate';
|
||
|
import { IUnleashConfig } from './lib/types/option';
|
||
|
|
||
|
log.setLogLevel('error');
|
||
|
|
||
|
export async function migrateDb({ db }: IUnleashConfig): Promise<void> {
|
||
|
const custom = { ...db, connectionTimeoutMillis: 10000 };
|
||
|
|
||
|
const dbm = getInstance(true, {
|
||
|
cwd: __dirname,
|
||
|
config: { custom },
|
||
|
env: 'custom',
|
||
|
});
|
||
|
|
||
|
return dbm.up();
|
||
|
}
|
||
|
|
||
|
// This exists to ease testing
|
||
|
export async function resetDb({ db }: IUnleashConfig): Promise<void> {
|
||
|
const custom = { ...db, connectionTimeoutMillis: 10000 };
|
||
|
|
||
|
const dbm = getInstance(true, {
|
||
|
cwd: __dirname,
|
||
|
config: { custom },
|
||
|
env: 'custom',
|
||
|
});
|
||
|
|
||
|
return dbm.reset();
|
||
|
}
|