diff --git a/.github/workflows/test-cli-with-database.yml b/.github/workflows/test-cli-with-database.yml index c1763bddd8..541dd54e8e 100644 --- a/.github/workflows/test-cli-with-database.yml +++ b/.github/workflows/test-cli-with-database.yml @@ -8,7 +8,6 @@ jobs: NODE_ENV: CI REDIS_URL: redis://localhost:6379 DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test" - POSTGRES_URL: "postgres://postgres:postgres@localhost/cli-test" services: redis: image: redis diff --git a/integration-tests/modules/__tests__/modules/load-standalone.ts b/integration-tests/modules/__tests__/modules/load-standalone.ts index 19ff640689..0e58a5f68c 100644 --- a/integration-tests/modules/__tests__/modules/load-standalone.ts +++ b/integration-tests/modules/__tests__/modules/load-standalone.ts @@ -9,11 +9,11 @@ medusaIntegrationTestRunner({ testSuite: ({ dbConfig: { clientUrl } }) => { describe("Standalone Modules", () => { beforeAll(async () => { - process.env.POSTGRES_URL = clientUrl + process.env.DATABASE_URL = clientUrl }) afterAll(async () => { - process.env.POSTGRES_URL = undefined + process.env.DATABASE_URL = undefined }) it("Should migrate database and initialize Product module using connection string from environment variable ", async function () { diff --git a/packages/cli/create-medusa-app/src/utils/prepare-project.ts b/packages/cli/create-medusa-app/src/utils/prepare-project.ts index fcb167288a..4de4495504 100644 --- a/packages/cli/create-medusa-app/src/utils/prepare-project.ts +++ b/packages/cli/create-medusa-app/src/utils/prepare-project.ts @@ -9,7 +9,8 @@ import type { Client } from "pg" const ADMIN_EMAIL = "admin@medusa-test.com" const STORE_CORS = "http://localhost:8000,https://docs.medusajs.com" -const ADMIN_CORS = "http://localhost:7000,http://localhost:7001,https://docs.medusajs.com" +const ADMIN_CORS = + "http://localhost:7000,http://localhost:7001,https://docs.medusajs.com" const AUTH_CORS = ADMIN_CORS const DEFAULT_REDIS_URL = "redis://localhost:6379" @@ -72,13 +73,13 @@ export default async ({ let env = `MEDUSA_ADMIN_ONBOARDING_TYPE=${onboardingType}${EOL}STORE_CORS=${STORE_CORS}${EOL}ADMIN_CORS=${ADMIN_CORS}${EOL}AUTH_CORS=${AUTH_CORS}${EOL}REDIS_URL=${DEFAULT_REDIS_URL}${EOL}JWT_SECRET=supersecret${EOL}COOKIE_SECRET=supersecret` if (!skipDb) { - env += `${EOL}DATABASE_URL=${dbConnectionString}${EOL}POSTGRES_URL=${dbConnectionString}` + env += `${EOL}DATABASE_URL=${dbConnectionString}` } if (nextjsDirectory) { env += `${EOL}MEDUSA_ADMIN_ONBOARDING_NEXTJS_DIRECTORY=${nextjsDirectory}` } - + fs.appendFileSync(path.join(directory, `.env`), env) factBoxOptions.interval = displayFactBox({ @@ -183,10 +184,7 @@ export default async ({ await processManager.runProcess({ process: async () => { const proc = await execute( - [ - `npx medusa user -e ${ADMIN_EMAIL} --invite`, - npxOptions, - ], + [`npx medusa user -e ${ADMIN_EMAIL} --invite`, npxOptions], { verbose, needOutput: true } ) diff --git a/packages/core/utils/src/modules-sdk/__tests__/load-database-config.spec.ts b/packages/core/utils/src/modules-sdk/__tests__/load-database-config.spec.ts index 3768f4be0f..83ed0923af 100644 --- a/packages/core/utils/src/modules-sdk/__tests__/load-database-config.spec.ts +++ b/packages/core/utils/src/modules-sdk/__tests__/load-database-config.spec.ts @@ -2,20 +2,20 @@ import { loadDatabaseConfig } from "../load-module-database-config" describe("loadDatabaseConfig", function () { afterEach(() => { - delete process.env.POSTGRES_URL - delete process.env.MEDUSA_POSTGRES_URL - delete process.env.PRODUCT_POSTGRES_URL + delete process.env.DATABASE_URL + delete process.env.MEDUSA_DATABASE_URL + delete process.env.PRODUCT_DATABASE_URL }) it("should return the local configuration using the environment variable respecting their precedence", function () { - process.env.MEDUSA_POSTGRES_URL = "postgres://localhost:5432/medusa" - process.env.PRODUCT_POSTGRES_URL = "postgres://localhost:5432/product" - process.env.POSTGRES_URL = "postgres://localhost:5432/share_db" + process.env.MEDUSA_DATABASE_URL = "postgres://localhost:5432/medusa" + process.env.PRODUCT_DATABASE_URL = "postgres://localhost:5432/product" + process.env.DATABASE_URL = "postgres://localhost:5432/share_db" let config = loadDatabaseConfig("product") expect(config).toEqual({ - clientUrl: process.env.PRODUCT_POSTGRES_URL, + clientUrl: process.env.PRODUCT_DATABASE_URL, driverOptions: { connection: { ssl: false, @@ -25,11 +25,11 @@ describe("loadDatabaseConfig", function () { schema: "", }) - delete process.env.PRODUCT_POSTGRES_URL + delete process.env.PRODUCT_DATABASE_URL config = loadDatabaseConfig("product") expect(config).toEqual({ - clientUrl: process.env.MEDUSA_POSTGRES_URL, + clientUrl: process.env.MEDUSA_DATABASE_URL, driverOptions: { connection: { ssl: false, @@ -39,11 +39,11 @@ describe("loadDatabaseConfig", function () { schema: "", }) - delete process.env.MEDUSA_POSTGRES_URL + delete process.env.MEDUSA_DATABASE_URL config = loadDatabaseConfig("product") expect(config).toEqual({ - clientUrl: process.env.POSTGRES_URL, + clientUrl: process.env.DATABASE_URL, driverOptions: { connection: { ssl: false, @@ -55,11 +55,11 @@ describe("loadDatabaseConfig", function () { }) it("should return the remote configuration using the environment variable", function () { - process.env.POSTGRES_URL = "postgres://https://test.com:5432/medusa" + process.env.DATABASE_URL = "postgres://https://test.com:5432/medusa" let config = loadDatabaseConfig("product") expect(config).toEqual({ - clientUrl: process.env.POSTGRES_URL, + clientUrl: process.env.DATABASE_URL, driverOptions: { connection: { ssl: { @@ -71,12 +71,12 @@ describe("loadDatabaseConfig", function () { schema: "", }) - delete process.env.POSTGRES_URL - process.env.PRODUCT_POSTGRES_URL = "postgres://https://test.com:5432/medusa" + delete process.env.DATABASE_URL + process.env.PRODUCT_DATABASE_URL = "postgres://https://test.com:5432/medusa" config = loadDatabaseConfig("product") expect(config).toEqual({ - clientUrl: process.env.PRODUCT_POSTGRES_URL, + clientUrl: process.env.PRODUCT_DATABASE_URL, driverOptions: { connection: { ssl: { @@ -90,7 +90,7 @@ describe("loadDatabaseConfig", function () { }) it("should return the local configuration using the options", function () { - process.env.POSTGRES_URL = "postgres://localhost:5432/medusa" + process.env.DATABASE_URL = "postgres://localhost:5432/medusa" const options = { database: { clientUrl: "postgres://localhost:5432/medusa-test", @@ -112,7 +112,7 @@ describe("loadDatabaseConfig", function () { }) it("should return the local configuration using the options", function () { - process.env.POSTGRES_URL = "postgres://localhost:5432/medusa" + process.env.DATABASE_URL = "postgres://localhost:5432/medusa" const options = { database: { clientUrl: "postgres://127.0.0.1:5432/medusa-test", @@ -134,7 +134,7 @@ describe("loadDatabaseConfig", function () { }) it("should return the remote configuration using the options", function () { - process.env.POSTGRES_URL = "postgres://localhost:5432/medusa" + process.env.DATABASE_URL = "postgres://localhost:5432/medusa" const options = { database: { clientUrl: "postgres://https://test.com:5432/medusa-test", @@ -158,7 +158,7 @@ describe("loadDatabaseConfig", function () { }) it("should return the local configuration using the client url ssl_mode=disable", function () { - process.env.POSTGRES_URL = "postgres://localhost:5432/medusa" + process.env.DATABASE_URL = "postgres://localhost:5432/medusa" const options = { database: { clientUrl: @@ -181,7 +181,7 @@ describe("loadDatabaseConfig", function () { }) it("should return the remote configuration using the client url ssl_mode=false", function () { - process.env.POSTGRES_URL = "postgres://localhost:5432/medusa" + process.env.DATABASE_URL = "postgres://localhost:5432/medusa" const options = { database: { clientUrl: @@ -212,7 +212,7 @@ describe("loadDatabaseConfig", function () { } expect(error.message).toEqual( - "No database clientUrl provided. Please provide the clientUrl through the [MODULE]_POSTGRES_URL, MEDUSA_POSTGRES_URL or POSTGRES_URL environment variable or the options object in the initialize function." + "No database clientUrl provided. Please provide the clientUrl through the [MODULE]_DATABASE_URL, MEDUSA_DATABASE_URL or DATABASE_URL environment variable or the options object in the initialize function." ) }) }) diff --git a/packages/core/utils/src/modules-sdk/load-module-database-config.ts b/packages/core/utils/src/modules-sdk/load-module-database-config.ts index 6f1af15c01..8f1f856712 100644 --- a/packages/core/utils/src/modules-sdk/load-module-database-config.ts +++ b/packages/core/utils/src/modules-sdk/load-module-database-config.ts @@ -57,7 +57,7 @@ function getDatabaseUrl( /** * Load the config for the database connection. The options can be retrieved - * e.g through PRODUCT_* (e.g PRODUCT_POSTGRES_URL) or * (e.g POSTGRES_URL) environment variables or the options object. + * e.g through PRODUCT_* (e.g PRODUCT_DATABASE_URL) or * (e.g DATABASE_URL) environment variables or the options object. * @param options * @param moduleName */ @@ -70,13 +70,13 @@ export function loadDatabaseConfig( "clientUrl" | "schema" | "driverOptions" | "debug" > { const clientUrl = - options?.database?.clientUrl ?? getEnv("POSTGRES_URL", moduleName) + options?.database?.clientUrl ?? getEnv("DATABASE_URL", moduleName) const database = { clientUrl, - schema: getEnv("POSTGRES_SCHEMA", moduleName) ?? "public", + schema: getEnv("DATABASE_SCHEMA", moduleName) ?? "public", driverOptions: JSON.parse( - getEnv("POSTGRES_DRIVER_OPTIONS", moduleName) || + getEnv("DATABASE_DRIVER_OPTIONS", moduleName) || JSON.stringify(getDefaultDriverOptions(clientUrl)) ), debug: false, @@ -98,7 +98,7 @@ export function loadDatabaseConfig( if (!database.clientUrl && !silent && !database.connection) { throw new MedusaError( MedusaError.Types.INVALID_ARGUMENT, - "No database clientUrl provided. Please provide the clientUrl through the [MODULE]_POSTGRES_URL, MEDUSA_POSTGRES_URL or POSTGRES_URL environment variable or the options object in the initialize function." + "No database clientUrl provided. Please provide the clientUrl through the [MODULE]_DATABASE_URL, MEDUSA_DATABASE_URL or DATABASE_URL environment variable or the options object in the initialize function." ) } diff --git a/packages/modules/product/README.md b/packages/modules/product/README.md index ac7b6623d8..730ccf89dd 100644 --- a/packages/modules/product/README.md +++ b/packages/modules/product/README.md @@ -23,7 +23,7 @@ npm install @medusajs/product 2\. Add Database URL to your environment variables ```bash -POSTGRES_URL= +DATABASE_URL= ``` 3\. Apply database migrations diff --git a/www/apps/resources/app/deployment/medusa-application/railway/page.mdx b/www/apps/resources/app/deployment/medusa-application/railway/page.mdx index 405225fc64..37d0e0cb29 100644 --- a/www/apps/resources/app/deployment/medusa-application/railway/page.mdx +++ b/www/apps/resources/app/deployment/medusa-application/railway/page.mdx @@ -53,7 +53,6 @@ module.exports = defineConfig({ workerMode: process.env.MEDUSA_WORKER_MODE, }, }) - ``` Later, you’ll set different values of the `MEDUSA_WORKER_MODE` environment variable for each Medusa application deployment. @@ -80,7 +79,6 @@ module.exports = defineConfig({ disable: process.env.DISABLE_MEDUSA_ADMIN === "true", }, }) - ``` Later, you’ll set different values of the `DISABLE_MEDUSA_ADMIN` environment variable. @@ -96,7 +94,6 @@ module.exports = defineConfig({ redisUrl: process.env.REDIS_URL, }, }) - ``` --- @@ -150,13 +147,13 @@ module.exports = defineConfig({ // ... [Modules.CACHE]: { resolve: "@medusajs/cache-redis", - options: { + options: { redisUrl: process.env.REDIS_URL, }, }, [Modules.EVENT_BUS]: { resolve: "@medusajs/event-bus-redis", - options: { + options: { redisUrl: process.env.REDIS_URL, }, }, @@ -240,7 +237,6 @@ DISABLE_MEDUSA_ADMIN=true MEDUSA_WORKER_MODE=worker PORT=9000 DATABASE_URL=${{Postgres.DATABASE_PUBLIC_URL}} -POSTGRES_URL=${{Postgres.DATABASE_PUBLIC_URL}} REDIS_URL=${{Redis.REDIS_PUBLIC_URL}} ``` @@ -279,7 +275,7 @@ You can either generate a random domain name or set a custom one. To do that: 2. Choose the Settings tab. 3. Scroll down to the Networking section. 4. Under Public Networking, click on Generate domain to generate a domain name or Custom domain to add your custom domain. - 1. Choose the `9000` port. + 1. Choose the `9000` port. 5. Save the changes. ### Additional Configuration if Deploying with Admin @@ -349,7 +345,6 @@ DISABLE_MEDUSA_ADMIN=false MEDUSA_WORKER_MODE=worker PORT=9000 DATABASE_URL=${{Postgres.DATABASE_PUBLIC_URL}} -POSTGRES_URL=${{Postgres.DATABASE_PUBLIC_URL}} REDIS_URL=${{Redis.REDIS_PUBLIC_URL}} ```