Primary key to reassign to a different shard
New shard binding name where the data should be moved
Name of the table containing the record to migrate
Promise that resolves when reassignment and migration are complete
// Move a user from east to west coast for better latency
try {
await reassignShard('user-california-123', 'db-west', 'users');
console.log('User successfully moved to west coast shard');
} catch (error) {
console.error('Reassignment failed:', error.message);
}
// Load balancing: move high-activity user to dedicated shard
await reassignShard('user-enterprise-456', 'db-dedicated', 'users');
Reassigns a primary key to a different shard
Moves a primary key and its associated data from one shard to another. This operation is useful for load balancing, shard maintenance, or geographic redistribution of data.
The reassignment process:
Note: This operation involves data migration and should be used carefully in production environments. Consider the impact on ongoing queries.