Add app subscription migration commands - #8399
Conversation
Assisted-By: devx/bb753bc6-d4c5-4a52-8d97-044f4b1a3497
Assisted-By: devx/bb753bc6-d4c5-4a52-8d97-044f4b1a3497
dmerand
left a comment
There was a problem hiding this comment.
I think there are a couple of minor changes we can make to structure here to better-align with repo guidance + also prepare these commands for incoming changes.
Context: Shopify CLI is moving finite commands toward typed result contracts. In that model, command execution returns structured domain data, while a CLI adapter decides whether to render terminal text or encode JSON. This lets the same execution support other adapters later and ensures --json emits exactly one document, including when useful data exists alongside an unsuccessful outcome.
Assisted-By: devx/bb753bc6-d4c5-4a52-8d97-044f4b1a3497
|
Submission and cancellation execution now return typed domain results, while command-local codecs and presenters own JSON/text rendering and exit status. Expected data-bearing failures produce one structured result and one JSON document; protocol/invariant failures remain exceptions. I believe this work should now align better with the document you referenced. |
gonzaloriestra
left a comment
There was a problem hiding this comment.
Could you share tophatting instructions? A demo would be useful as well.
Also, the PR is too large, next time please split in a stack 🙏
Assisted-By: devx/bb753bc6-d4c5-4a52-8d97-044f4b1a3497
Assisted-By: devx/bb753bc6-d4c5-4a52-8d97-044f4b1a3497
6b7cc93 to
661e68c
Compare
|
/snapit |
|
🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm. Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260828075026Caution After installing, validate the version by running |
Why
Partners migrating legacy manual-billing subscriptions to Shopify-managed app pricing need a safe, scriptable CLI workflow.
What changed
Adds four core Shopify CLI commands:
shopify app subscription-migrations scheduleshopify app subscription-migrations unscheduleshopify app subscription-migrations statusshopify app subscription-migrations cancelThe commands:
--client-idoverride;--input, stdin, or--input -;--idflags for multi-batch status and cancellation;cancelstops an operation from processing additional shops. It does not undo shops that have already been scheduled or migrated;unscheduleis the separate reversal workflow.Top-hatting
Caution
These commands change real app-subscription migration state. Use only a controlled test app and shop, and confirm the intended plan and shop before submitting.
Prerequisites
Run commands from the app project. To select another accessible app explicitly, add
--client-id <client-id>.Schedule one subscription
Create
/tmp/subscription-migrations.csv:Submit and watch the operation:
Preserve the root idempotency key and every operation GID printed by the command.
COMPLETEDmeans processing is terminal; inspect the per-shop result code before treating the migration as successful.Check status
pnpm shopify app subscription-migrations status \ --id 'gid://shopify/AppSubscriptionMigrationOperation/123' \ --watchRepeat
--idfor every operation returned by a multi-batch submission. Add--jsonto verify that stdout contains one structured document while progress remains on stderr.Cancel unprocessed work
pnpm shopify app subscription-migrations cancel \ --id 'gid://shopify/AppSubscriptionMigrationOperation/123'Cancellation prevents additional shops from being processed. It does not reverse shops that were already scheduled or migrated.
Unschedule a reversible migration
You can reuse
/tmp/subscription-migrations.csvfrom earlier. As long as the input has ashop_idcolumn, it will correctly create an unscheduling job. Or, you can create a separate file/tmp/subscription-migrations-unschedule.csv:shop_id gid://shopify/Shop/123456789Then run:
Only run this while the migration remains reversible.
Backend dependency
Uses the Partners CLI GraphQL fields introduced by Shopify/partners#63097:
appSubscriptionMigrationOperationCreateappSubscriptionMigrationOperationappSubscriptionMigrationOperationCancelThe app Client ID is a selector rather than authorization. Partners derives organization membership from the authenticated CLI session and enforces migration permissions and app scoping.
Testing
pnpm vitest run packages/app/src/cli— 2,258 tests passedpnpm --filter @shopify/app lintpnpm --filter @shopify/app type-checkpnpm --filter @shopify/app buildpnpm knip