| title | request_migration |
|---|---|
| description | Requests migration of all active subscribers from an old plan to a new one. Each subscriber must accept or reject. Both plans must belong to the same merchant. |
fn request_migration(env: Env, merchant: Address, old_plan_id: u64, new_plan_id: u64)Initiates a migration from an old plan to a new plan. This sets the migration_target field on all active subscriptions under the old plan. Each subscriber must individually call accept_migration or reject_migration - the migration is never automatic.
| Name | Type | Description |
|---|---|---|
merchant |
Address |
The merchant's Stellar address. Must own both plans. |
old_plan_id |
u64 |
The plan ID to migrate subscribers from. |
new_plan_id |
u64 |
The plan ID to migrate subscribers to. |
merchant.require_auth();The merchant must own both the old and new plans.
None (void).
| Event | Topics | Data |
|---|---|---|
mig_req |
old_plan_id, new_plan_id |
Migration details |
| Code | Name | Description |
|---|---|---|
| 11 | MerchantMismatch |
The old and new plans belong to different merchants. |
| 7 | PlanInactive |
The new plan is not active. |
```typescript import { VowenaClient, NETWORKS } from "@vowena/sdk";
const client = new VowenaClient({
contractId: NETWORKS.testnet.contractId,
rpcUrl: NETWORKS.testnet.rpcUrl,
networkPassphrase: NETWORKS.testnet.networkPassphrase,
});
// Migrate all subscribers from plan 1 to plan 2
const tx = await client.buildRequestMigration(
"GMERCHANT...ADDR", // Merchant's address
1, // Old plan ID
2 // New plan ID
);
const signedXdr = await signTransaction(tx);
await client.submitTransaction(signedXdr);
```