-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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(medusa): Added models + repo for products in multiple categories #3083
Conversation
🦋 Changeset detectedLatest commit: 3d79cb9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
7ac58bf
to
45d41e7
Compare
45d41e7
to
ab85222
Compare
ab85222
to
f2fe3ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Regarding creating the join-table ProductCategoryProduct
it's generally not required to create models explicitly for the join-tables for many-to-many relations and we've generally not done so previously without an explicit purpose (discount conditions).
I dont mind if we include it with a specific purpose, otherwise I think we should hold out on including it. wdyt?
(edit: I dont think it's a bad pattern I just want us to be aware if we start doing things differently so we know to create the rest of these relations if we choose that pattern, and to communicate that we follow a different standard going forward in order to ship consistent code)
53ec031
to
550f8b1
Compare
packages/medusa/src/migrations/1674455083104-product_category_product.ts
Show resolved
Hide resolved
a20d8e0
to
08f2e6d
Compare
packages/medusa/src/migrations/1674455083104-product_category_product.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, added a suggestion for the FKs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with comments 😄 I think we could remove a couple more of the db columns for the jointable as we dont have a model for them anymore and they just denote the relationship.
packages/medusa/src/migrations/1674455083104-product_category_product.ts
Outdated
Show resolved
Hide resolved
await queryRunner.query( | ||
` | ||
CREATE TABLE "product_category_product" ( | ||
"id" character varying NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: remove id
column since we don't use a model for this anymore
"created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), | ||
"updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: remove created_at
and updated_at
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comments from phil are the last, I don't have other thing to say. Once it is done I will be able to approve 💪
…product.ts Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @adrien2p will you have a look to see if we can turn it green 💚
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
What:
Introduces a model and a migration to assign multiple products to a category.
Why:
To allow products to be added to multiple categories
How:
RESOLVES CORE-1027