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:
1 parent
3f499c829e
commit
b6e4435c23
2 files changed
+20
-17
No files matched your search
@@ -46,21 +46,23 @@ export function buildMigrationScript({ moduleName, models, pathToMigrations }) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const migrator = orm.getMigrator()
|
const migrator = orm.getMigrator()
|
||||||
|
|
||||||
const pendingMigrations = await migrator.getPendingMigrations()
|
const pendingMigrations = await migrator.getPendingMigrations()
|
||||||
logger.info(
|
|
||||||
`Running pending migrations: ${JSON.stringify(
|
|
||||||
pendingMigrations,
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)}`
|
|
||||||
)
|
|
||||||
|
|
||||||
await migrator.up({
|
if (pendingMigrations.length) {
|
||||||
migrations: pendingMigrations.map((m) => m.name),
|
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) {
|
} catch (error) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`${upperCaseFirst(
|
`${upperCaseFirst(
|
||||||
|
|||||||
@@ -66,17 +66,18 @@ export function getMigration(
|
|||||||
} else {
|
} else {
|
||||||
logger.info(`Skipping "${tableName}" migration.`)
|
logger.info(`Skipping "${tableName}" migration.`)
|
||||||
}*/
|
}*/
|
||||||
logger.info(
|
// Note: Temporarily skipping this for handling no logs on the CI. Bring this back if necessary.
|
||||||
`Link module "${serviceName}" table update skipped because the table already exists. Please write your own migration if needed.`
|
// logger.info(
|
||||||
)
|
// `Link module('${serviceName}'): Table already exists. Write your own migration if needed.`
|
||||||
|
// )
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await generator.createSchema()
|
await generator.createSchema()
|
||||||
|
|
||||||
logger.info(`Link module "${serviceName}" migration executed`)
|
logger.info(`Link module('${serviceName}'): Migration executed`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Link module "${serviceName}" migration failed to run - Error: ${
|
`Link module('${serviceName}'): Migration failed - Error: ${
|
||||||
error.errros ?? error
|
error.errros ?? error
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user