chore: cleanup migrations logs (#7924)

what:

when running `medusa run migrations`, cleanup logs with short descriptive message.

Before:

<img width="1262" alt="Screenshot 2024-07-03 at 14 31 36" src="https://github.com/medusajs/medusa/assets/5105988/504e9c24-371c-476d-9b6d-2dfe1a4088dc">

After:

<img width="1004" alt="Screenshot 2024-07-03 at 14 42 57" src="https://github.com/medusajs/medusa/assets/5105988/a89eaed5-04a4-4efb-a2e9-ca480f1eaa6e">
This commit is contained in:
Riqwan Thamir
2024-07-03 15:53:59 +02:00
committed by GitHub
parent 3f499c829e
commit b6e4435c23
2 changed files with 20 additions and 17 deletions

View File

@@ -46,21 +46,23 @@ export function buildMigrationScript({ moduleName, models, pathToMigrations }) {
try {
const migrator = orm.getMigrator()
const pendingMigrations = await migrator.getPendingMigrations()
logger.info(
`Running pending migrations: ${JSON.stringify(
pendingMigrations,
null,
2
)}`
)
await migrator.up({
migrations: pendingMigrations.map((m) => m.name),
})
if (pendingMigrations.length) {
logger.info(
`Pending migrations: ${JSON.stringify(pendingMigrations, null, 2)}`
)
logger.info(`${upperCaseFirst(moduleName)} module migration executed`)
await migrator.up({
migrations: pendingMigrations.map((m) => m.name),
})
logger.info(
`${upperCaseFirst(moduleName)} module: ${
pendingMigrations.length
} migration files executed`
)
}
} catch (error) {
logger.error(
`${upperCaseFirst(

View File

@@ -66,17 +66,18 @@ export function getMigration(
} else {
logger.info(`Skipping "${tableName}" migration.`)
}*/
logger.info(
`Link module "${serviceName}" table update skipped because the table already exists. Please write your own migration if needed.`
)
// Note: Temporarily skipping this for handling no logs on the CI. Bring this back if necessary.
// logger.info(
// `Link module('${serviceName}'): Table already exists. Write your own migration if needed.`
// )
} else {
try {
await generator.createSchema()
logger.info(`Link module "${serviceName}" migration executed`)
logger.info(`Link module('${serviceName}'): Migration executed`)
} catch (error) {
logger.error(
`Link module "${serviceName}" migration failed to run - Error: ${
`Link module('${serviceName}'): Migration failed - Error: ${
error.errros ?? error
}`
)