Skip to content

Commit

Permalink
add logging + upgrade assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdml committed Dec 8, 2023
1 parent c43d2ab commit 3e32af6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cloud-cli/userdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 3e32af6

Please sign in to comment.