breaking: rework how links database migrations are managed (#8162)

This commit is contained in:
Adrien de Peretti
2024-07-22 13:12:23 +05:30
committed by GitHub
parent f435c6c7f6
commit f74fdcb644
24 changed files with 1090 additions and 264 deletions
@@ -40,8 +40,25 @@ export async function initDb({
try {
const {
runMedusaAppMigrations,
getLinksExecutionPlanner,
} = require("@medusajs/medusa/dist/loaders/medusa-app")
await runMedusaAppMigrations({ configModule, container })
const planner = await getLinksExecutionPlanner({
configModule,
container,
})
const actionPlan = await planner.createPlan()
await planner.executePlan(actionPlan)
/**
* cleanup temporary created resources for the migrations
* @internal I didnt find a god place to put that, should we eventually add a close function
* to the planner to handle that part? so that you would do planner.close() and it will handle the cleanup
* automatically just like we usually do for the classic migrations actions
*/
const { MedusaModule } = require("@medusajs/modules-sdk")
MedusaModule.clearInstances()
} catch (err) {
console.error("Something went wrong while running the migrations")
throw err