Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(link-modules,modules-sdk,pricing): Medusa App Migrations + Core compatible migrations #5317

Merged
merged 18 commits into from
Oct 10, 2023

Conversation

riqwan
Copy link
Contributor

@riqwan riqwan commented Oct 9, 2023

RESOLVES CORE-1514
RESOLVES CORE-1513

@changeset-bot
Copy link

changeset-bot bot commented Oct 9, 2023

🦋 Changeset detected

Latest commit: d9640c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@medusajs/link-modules Patch
@medusajs/modules-sdk Patch
@medusajs/pricing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2023 0:05am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2023 0:05am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Oct 10, 2023 0:05am

@riqwan riqwan marked this pull request as ready for review October 9, 2023 09:23
@riqwan riqwan requested a review from a team as a code owner October 9, 2023 09:23
@riqwan riqwan force-pushed the feat/pricing-integration branch from 0a2693a to e114b66 Compare October 9, 2023 14:39
Comment on lines +24 to +25
// TODO: Remove this when product module is the default product service
isInternalService: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what does this do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to load it from the core and not as being a module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need that if the product module is not required to run the pricing module, in that case the pricing modue is linked to the internal core service and the pivot table is managed in the core

Comment on lines +24 to +25
// TODO: Remove this when product module is the default product service
isInternalService: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need that if the product module is not required to run the pricing module, in that case the pricing modue is linked to the internal core service and the pivot table is managed in the core

packages/modules-sdk/src/medusa-app.ts Outdated Show resolved Hide resolved
packages/modules-sdk/src/medusa-app.ts Outdated Show resolved Hide resolved
packages/pricing/src/migrations/Migration20231009090247.ts Outdated Show resolved Hide resolved
Comment on lines 17 to 20
// TODO: This is added here to make the schema compatible
// with the core. Remove this when core is no longer running migrations
@Property({ columnType: "boolean", nullable: true })
includes_tax?: boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: If the module is shared and use the core connection, then the migration is managed by the core and the module should not run its migration. it should run its migrations only if it is isolated otherwise we rely on the core. wdyt? In that case we could remove this from here and the migration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of that idea. The model and schema can easily be corrupted by one another. My ideal scenario would actually be to scope the tables by the name of the module. In a world of modules, I think this would actually be a good thing.

Additionally, we're making an assumption that the core models will be exactly the same as the module models. Which isn't the case with pricing models. There are other migrations that need to run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry i thought i did remove this comment 🤣 but i wanted to start a discussion on how we would handle this. Cause another problem could be that when using the module the user might now expect to loose his current data in the core, so i think it is a larger topic that needs to be discussed

packages/pricing/src/models/money-amount.ts Outdated Show resolved Hide resolved
@riqwan riqwan requested review from adrien2p and srindom October 10, 2023 10:26
@adrien2p
Copy link
Member

check if constraints needs to be removed, if any core table needs to be altered when the pricing module is shared, then create a feature flag and a migration in the core that only run under that flag and the migration will manage the alteration of the core tables instead of the module

@riqwan riqwan merged commit b62af61 into develop Oct 10, 2023
12 checks passed
@github-actions github-actions bot mentioned this pull request Oct 10, 2023
@olivermrbl
Copy link
Contributor

/snapshot-this

pKorsholm pushed a commit that referenced this pull request Oct 11, 2023
…compatible migrations (#5317)

* chore: remove skipping logic for migrations

* chore: medusa app returns migrations to run for modules

* chore: added migration for feature compatible

* chore: added changelog

* chore: create table only if it does not exist

* chore: update migration to pluck from registered modules

* chore: cleanup

* chore: make product an internal service temp

* chore: added options and deps to module

* chore: added link module options

* chore: remove duplicate

* chore: added missing column names in core + remove from model

* chore: scope migrations to only to create if not exist - money amount, currency

---------

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
@riqwan riqwan deleted the feat/pricing-integration branch October 26, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants