From b2cf74e878c3be3a079d83e93a869bffa6ee3387 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 30 Jun 2019 04:49:30 +0900 Subject: [PATCH] Create accept-migration.ts --- src/tools/accept-migration.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/tools/accept-migration.ts diff --git a/src/tools/accept-migration.ts b/src/tools/accept-migration.ts new file mode 100644 index 0000000000..addce86f1f --- /dev/null +++ b/src/tools/accept-migration.ts @@ -0,0 +1,25 @@ +// ex) node built/tools/accept-migration Yo 1000000000001 + +import { createConnection } from 'typeorm'; +import config from '../config'; + +createConnection({ + type: 'postgres', + host: config.db.host, + port: config.db.port, + username: config.db.user, + password: config.db.pass, + database: config.db.db, + extra: config.db.extra, + synchronize: false, + dropSchema: false, +}).then(c => { + c.query(`INSERT INTO migrations(timestamp,name) VALUES (${process.argv[3]}, '${process.argv[2]}${process.argv[3]}');`).then(() => { + console.log('done'); + process.exit(0); + }).catch(e => { + console.log('ERROR:'); + console.log(e); + process.exit(1); + }); +});