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(cart): Migration file #6156

Merged
merged 7 commits into from
Jan 29, 2024
Merged

feat(cart): Migration file #6156

merged 7 commits into from
Jan 29, 2024

Conversation

olivermrbl
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Jan 22, 2024

⚠️ No Changeset found

Latest commit: 763c1a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Jan 22, 2024

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

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2024 8:03pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Jan 28, 2024 8:03pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Jan 28, 2024 8:03pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jan 28, 2024 8:03pm

export class CartModuleSetup20240122122952 extends Migration {
async up(): Promise<void> {
this.addSql(
'create table "cart_address" ("id" text not null, "customer_id" text null, "company" text null, "first_name" text null, "last_name" text null, "address_1" text null, "address_2" text null, "city" text null, "country_code" text null, "province" text null, "postal_code" text null, "phone" text null, "metadata" jsonb null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), constraint "cart_address_pkey" primary key ("id"));'
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to add if not exists everywhere. Creating tables, constraints and indexes.
That will avoid issues when modularizing things if you want to move it to another DB for example, where you copy all the data, but you might not have the migrations of that module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

Copy link
Contributor

@carlos-r-l-rodrigues carlos-r-l-rodrigues left a comment

Choose a reason for hiding this comment

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

LGTM
I just left a few suggestions, and a few optional indexes in case we have these entites publicly exposed and we want the hability to query them from the other module. eg: Tax -> CartLineItemsTaxLines
If we won't have them and will only expand CartLineItemsTaxLines -> Tax, it is alright.

columnType: "text",
nullable: true,
index: "IDX_cart_region_id",
})
region_id?: string | null
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
region_id?: string | null
region_id: string | null = null

Copy link
Contributor Author

@olivermrbl olivermrbl Jan 28, 2024

Choose a reason for hiding this comment

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

I will clean up all cart data models with respect to our new convention in a separate PR. They haven't been updated since we decided to do = null

packages/cart/src/models/cart.ts Show resolved Hide resolved
@olivermrbl olivermrbl merged commit c15438c into develop Jan 29, 2024
16 checks passed
@olivermrbl olivermrbl deleted the feat/cm-migration branch January 29, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants