chamesu
Version:
This package contains all packages of the chat application.
41 lines (31 loc) • 1.04 kB
text/typescript
/*
* Copyright (c) 2022.
* Author Peter Placzek (tada5hi)
* For the full copyright and license information,
* view the LICENSE file that was distributed with this source code.
*/
import {Arguments, Argv, CommandModule} from "yargs";
import {buildConnectionOptions, runSeeder} from "typeorm-extension";
import {createConnection} from "typeorm";
interface ResetArguments extends Arguments {
}
export class ResetCommand implements CommandModule {
command = "reset";
describe = "Run reset operation.";
builder(args: Argv) {
return args;
}
async handler(args: ResetArguments) {
const connectionOptions = await buildConnectionOptions();
const connection = await createConnection(connectionOptions);
try {
await connection.synchronize(true);
await connection.runMigrations({transaction: "all"});
await runSeeder(connection);
} catch (e) {
throw e;
} finally {
await connection.close();
}
}
}