{"record":{"id":"ca273f5439537af3","repo":"medusajs/medusa","slug":"migrations-missing-please-run-medusa-migrations","errorCode":null,"errorMessage":"Migrations missing. Please run 'medusa migrations run' and try again.","messagePattern":"Migrations missing\\. Please run 'medusa migrations run' and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/core/utils/src/common/handle-postgres-database-error.ts","lineNumber":43,"sourceCode":"      ${EOL}\n      ${err.message}`\n    )\n  }\n\n  if (DatabaseErrorCode.wrongCredentials === err.code) {\n    throw new Error(\n      `The specified credentials does not exists for the specified PostgreSQL database.${EOL}${err.message}`\n    )\n  }\n\n  if (DatabaseErrorCode.notFound === err.code) {\n    throw new Error(\n      `The specified connection string for your PostgreSQL database might have illegal characters. Please check that it only contains allowed characters [a-zA-Z0-9]${EOL}${err.message}`\n    )\n  }\n\n  if (DatabaseErrorCode.migrationMissing === err.code) {\n    throw new Error(\n      `Migrations missing. Please run 'medusa migrations run' and try again.`\n    )\n  }\n\n  throw err\n}\n","sourceCodeStart":25,"sourceCodeEnd":50,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/core/utils/src/common/handle-postgres-database-error.ts#L25-L50","documentation":"Maps PostgreSQL error 42P01 (undefined_table). Medusa interprets it as the schema not being migrated: the tables the code expects do not exist yet.","triggerScenarios":"Running the server, admin, or integration tests against a fresh/empty database before running migrations; or migrations that ran against a different database than the runtime is using.","commonSituations":"New environments, after dropping the db, CI pipelines skipping the migration step, or DATABASE_URL differing between migrate and start.","solutions":["Run `npx medusa db migrate` (or `medusa migrations run`) against the same DATABASE_URL used at runtime","Verify all module migrations ran (medusa db migrate runs module migrations)","In CI add the migrate step before starting the app"],"exampleFix":"# before\nmedusa start\n# after\nmedusa db migrate && medusa start","handlingStrategy":"fallback","validationCode":"const { Client } = require('pg')\nconst c = new Client({ connectionString: process.env.DATABASE_URL }); await c.connect()\nconst { rows } = await c.query(\"SELECT to_regclass('public.product') AS t\"); await c.end()\nif (!rows[0].t) await exec('npx medusa db migrate')","typeGuard":null,"tryCatchPattern":"try { await start() } catch (e) { if (/Migrations missing/.test(e.message)) { await run('medusa db migrate'); await start() } else throw e }","preventionTips":["Always run migrations as a release/CI step before start","Use the same DATABASE_URL for migrate and start"],"tags":["postgres","migrations","database","startup"],"backgroundTag":"migrations-not-applied","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}