fix: allow setting DB_PORT and DATABASE_URL env variables (#11519)

Fixes: FRMW-2896

Closes: https://github.com/medusajs/medusa/issues/11502
This commit is contained in:
Harminder Virk
2025-02-19 13:37:15 +05:30
committed by GitHub
parent 30171f3dc4
commit 0e6ffad30f
2 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---
fix: allow setting DB_PORT and DATABASE_URL env variables

View File

@@ -102,6 +102,8 @@ async function generateMigrations(
const DB_HOST = process.env.DB_HOST ?? "localhost"
const DB_USERNAME = process.env.DB_USERNAME ?? ""
const DB_PASSWORD = process.env.DB_PASSWORD ?? ""
const DB_PORT = process.env.DB_PORT ? Number(process.env.DB_PORT) : 5432
const DATABASE_URL = process.env.DATABASE_URL
for (const moduleDescriptor of moduleDescriptors) {
logger.info(
@@ -113,8 +115,10 @@ async function generateMigrations(
{
entities: moduleDescriptor.entities,
host: DB_HOST,
port: DB_PORT,
user: DB_USERNAME,
password: DB_PASSWORD,
...(DATABASE_URL ? { clientUrl: DATABASE_URL } : {}),
migrations: {
path: moduleDescriptor.migrationsPath,
},