-
Notifications
You must be signed in to change notification settings - Fork 0
[codex] Fix workflow queue dedupe #444
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be5d86e
Fix workflow queue dedupe
ztomas-codes da1c74a
Keep workflow queue dedupe migration generic
ztomas-codes 45135c4
Fix workflow queue migration chain
ztomas-codes 50ce286
feat(store-reviews): require purchased product for reviews
ztomas-codes 95cdb04
Merge remote-tracking branch 'origin/master' into feature/queue-fix
ztomas-codes c8a6609
fix(queue-fix): Snapshot & Migration
ztomas-codes 9a77a8f
fix(queue-fix): Migration clear
ztomas-codes fbefe3a
fix(queue-fix): Workflow queue migration
ztomas-codes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
apps/medusa-be/src/modules/workflow-queue/migrations/Migration20260610110000.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Migration } from "@medusajs/framework/mikro-orm/migrations" | ||
|
|
||
| export class Migration20260610110000 extends Migration { | ||
| override async up(): Promise<void> { | ||
| this.addSql( | ||
| `DROP INDEX IF EXISTS "IDX_workflow_queue_item_workflow_order_id";` | ||
| ) | ||
| this.addSql( | ||
| `alter table if exists "workflow_queue_item" drop column if exists "order_id";` | ||
| ) | ||
| } | ||
|
|
||
| override async down(): Promise<void> { | ||
| this.addSql( | ||
| `alter table if exists "workflow_queue_item" add column if not exists "order_id" text null;` | ||
| ) | ||
| this.addSql( | ||
| `update "workflow_queue_item" set "order_id" = "arguments"->>'order_id' where "order_id" is null and "arguments" ? 'order_id';` | ||
| ) | ||
| this.addSql( | ||
| `CREATE INDEX IF NOT EXISTS "IDX_workflow_queue_item_workflow_order_id" ON "workflow_queue_item" ("workflow", "order_id") WHERE deleted_at IS NULL;` | ||
| ) | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
apps/medusa-be/src/modules/workflow-queue/migrations/Migration20260610120000.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Migration } from "@medusajs/framework/mikro-orm/migrations" | ||
|
|
||
| export class Migration20260610120000 extends Migration { | ||
| override async up(): Promise<void> { | ||
| this.addSql( | ||
| `alter table if exists "workflow_queue_item" add column if not exists "dedupe_key" text null;` | ||
| ) | ||
| this.addSql( | ||
| `update "workflow_queue_item" set "dedupe_key" = 'send-review-reminder-' || ("arguments"->>'order_id') where "workflow" = 'send-product-review-request' and "dedupe_key" is null and "arguments" ? 'order_id';` | ||
| ) | ||
| this.addSql( | ||
| `delete from "workflow_queue_item" a using (select ctid, row_number() over (partition by "workflow", "dedupe_key" order by "created_at" asc, "run_at" asc, "id" asc) as rn from "workflow_queue_item" where "deleted_at" is null and "dedupe_key" is not null) ranked where a.ctid = ranked.ctid and ranked.rn > 1;` | ||
|
tomas-cm1 marked this conversation as resolved.
Outdated
|
||
| ) | ||
| this.addSql( | ||
| `CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_queue_item_workflow_dedupe_key_unique" ON "workflow_queue_item" ("workflow", "dedupe_key") WHERE deleted_at IS NULL AND dedupe_key IS NOT NULL;` | ||
|
tomas-cm1 marked this conversation as resolved.
Outdated
|
||
| ) | ||
| } | ||
|
|
||
| override async down(): Promise<void> { | ||
| this.addSql( | ||
| `DROP INDEX IF EXISTS "IDX_workflow_queue_item_workflow_dedupe_key_unique";` | ||
| ) | ||
| this.addSql( | ||
| `alter table if exists "workflow_queue_item" drop column if exists "dedupe_key";` | ||
| ) | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
apps/medusa-be/src/modules/workflow-queue/migrations/Migration20260617104357.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { Migration } from "@medusajs/framework/mikro-orm/migrations"; | ||
|
|
||
| export class Migration20260617104357 extends Migration { | ||
|
|
||
| override async up(): Promise<void> { | ||
| this.addSql(`alter table if exists "workflow_queue_item" drop constraint if exists "workflow_queue_item_workflow_dedupe_key_unique";`); | ||
|
tomas-cm1 marked this conversation as resolved.
Outdated
tomas-cm1 marked this conversation as resolved.
Outdated
|
||
| this.addSql(`drop index if exists "IDX_workflow_queue_item_workflow_order_id";`); | ||
|
|
||
| this.addSql(`alter table if exists "workflow_queue_item" rename column "order_id" to "dedupe_key";`); | ||
|
tomas-cm1 marked this conversation as resolved.
Outdated
tomas-cm1 marked this conversation as resolved.
Outdated
|
||
| this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_queue_item_workflow_dedupe_key_unique" ON "workflow_queue_item" ("workflow", "dedupe_key") WHERE deleted_at IS NULL AND dedupe_key IS NOT NULL;`); | ||
|
greptile-apps[bot] marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| override async down(): Promise<void> { | ||
| this.addSql(`drop index if exists "IDX_workflow_queue_item_workflow_dedupe_key_unique";`); | ||
|
|
||
| this.addSql(`alter table if exists "workflow_queue_item" rename column "dedupe_key" to "order_id";`); | ||
| this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_queue_item_workflow_order_id" ON "workflow_queue_item" ("workflow", "order_id") WHERE deleted_at IS NULL;`); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.