Fixes #13735 ### What This Pull Request introduces new database migrations to remove multiple redundant indexes across several core modules, including product, cart, order, customer, and inventory. ### Why As detailed in issue #13735, a fresh Medusa installation produces numerous "Duplicate Index" warnings. These legacy indexes add unnecessary write overhead and provide no performance benefit. This PR cleans up the schema to resolve these warnings and improve database health. ### How I have added one new, reversible migration file for each of the five affected modules: - `@medusajs/product` - `@medusajs/cart` - `@medusajs/order` - `@medusajs/customer` - `@medusajs/inventory` Each migration's `up()` method safely drops the older, redundant index, and its `down()` method re-creates it, ensuring the change is fully reversible and non-destructive. ### Testing I have tested these migrations by following the local development workflow outlined in the `CONTRIBUTING.md` guide. 1. **Setup:** * Cloned my forked Medusa repository locally . * Created a separate, fresh test project using `npx create-medusa-app@latest my-medusa-store`. * The test project's PostgreSQL database, which already contained the schema with the duplicate indexes. 2. **Linking Local Source Code:** * In the test project's `package.json`, I modified all `@medusajs/*` dependencies and resolutions to point to the local packages in my forked repository (e.g., `"@medusajs/product": "file:../medusa/packages/modules/product"`). * From the test project's directory, I ran `yarn install` to link the local, modified Medusa source code into its `node_modules`. 3. **Build & Migration:** * Inside my forked Medusa repository, I ran `yarn build` to compile the new TypeScript migration files. * From the root of the **test project**, I then executed the migration command: `npx medusa migration run`. 4. **Verification:** * The command successfully identified and ran only the new migration files I had created. * I also confirmed via direct SQL queries that the old, redundant indexes were correctly dropped from all affected tables (`product_collection`, `customer_group`, etc.).
Medusa
Documentation | Website
Building blocks for digital commerce
Getting Started
Visit the Documentation to set up a Medusa application.
About Medusa
Medusa is a commerce platform with a built-in framework for customization that allows you to build custom commerce applications without reinventing core commerce logic. The framework and modules can be used to support advanced B2B or DTC commerce stores, marketplaces, distributor platforms, PoS systems, service businesses, or similar solutions that need foundational commerce primitives. All commerce modules are open-source and freely available on npm.
Learn more about Medusa’s architecture and commerce modules in the Docs.
Upgrades & Integrations
Follow the Release Notes to keep your Medusa project up-to-date.
Check out all available Medusa integrations.
Community & Contributions
The core team is available in GitHub Discussions, where you can create issues, share ideas, and discuss roadmap.
Our Contribution Guide describes how to contribute to the codebase and Docs.
Join our Discord server to meet and discuss with more than 14,000 other community members.
Other channels
License
Licensed under the MIT License.