From 3e32af6e30ed7957fbe9f35b3c76215af93c18f8 Mon Sep 17 00:00:00 2001 From: maxdml Date: Fri, 8 Dec 2023 06:25:10 +0000 Subject: [PATCH] add logging + upgrade assertion --- src/cloud-cli/userdb.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cloud-cli/userdb.ts b/src/cloud-cli/userdb.ts index bdae9cab8..2d5c10f51 100644 --- a/src/cloud-cli/userdb.ts +++ b/src/cloud-cli/userdb.ts @@ -159,15 +159,15 @@ export function migrate(): number { const cmd = `createdb -h ${configFile.database.hostname} -p ${configFile.database.port} ${userdbname} -U ${configFile.database.username} -w ${configFile.database.password} -e`; logger.info(cmd); try { - execSync(cmd); + const createDBCommandOutput = execSync(cmd).toString(); + logger.info(createDBCommandOutput); } catch (e) { logger.error("Database already exists or could not be created."); - return 1; } } let dbType = configFile.database.user_dbclient; - if (dbType == undefined) { + if (dbType === undefined) { dbType = "knex"; } @@ -177,10 +177,12 @@ export function migrate(): number { migratecommands?.forEach((cmd) => { const command = "npx " + dbType + " " + cmd; logger.info("Executing " + command); - execSync(command); + const migrateCommandOutput = execSync(command).toString(); + logger.info(migrateCommandOutput); }); } catch (e) { logger.error("Error running migration. Check database and if necessary, run npx dbos-cloud userdb rollback."); + logger.error(e); return 1; }