Skip to content

Implement migrate command - #276

Merged
prateek-kumar-improving merged 39 commits into
mainfrom
implement-migrate-command
Jul 30, 2026
Merged

Implement migrate command#276
prateek-kumar-improving merged 39 commits into
mainfrom
implement-migrate-command

Conversation

@prateek-kumar-improving

@prateek-kumar-improving prateek-kumar-improving commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implement the MIGRATE command for both standalone and cluster clients. Supports single-key migration (both clients), multi-key migration (standalone only), COPY/REPLACE flags, and AUTH/AUTH2 credentials.

Issue link

This Pull Request is linked to issue: #236
Linked issue: #275

Features / Behaviour Changes

  • Add ValkeyGlide::migrate(string $host, int $port, string|array $key, int $dstdb, int $timeout, bool $copy = false, bool $replace = false, mixed $credentials = null): ValkeyGlide|bool|string
  • Add ValkeyGlideCluster::migrate(...): same but single-key only
  • PHPRedis compatible signature
  • Returns true on success (OK/NOKEY), false on error
  • With OPT_REPLY_LITERAL enabled, returns raw status string ("OK" or "NOKEY") on success, false on failure
  • Cluster mode: single-key only (matching Java/Python/Go limitation)
  • Supports COPY, REPLACE, AUTH, and AUTH2

Implementation

  • execute_migrate_command() in valkey_glide_commands.c
  • MIGRATE_METHOD_IMPL macro using STANDARD_METHOD_IMPL
  • Migrate case added to prepare_message_args switch (alphabetized)
  • Increased core_command_args_t.args from [8] to [12]
  • Multi-key handled by iterating PHP array as individual STRING args
  • Credentials support: string → AUTH, array [username, password] → AUTH2
  • Test infrastructure: startDestinationServer()/stopDestinationServer() helpers using cluster_manager.py

Testing

Standalone tests (tests/ValkeyGlideTest.php) added.
Cluster tests (tests/ValkeyGlideClusterTest.php) added.
Build passes with -Werror, lint clean on all modified files.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@prateek-kumar-improving
prateek-kumar-improving marked this pull request as ready for review July 22, 2026 18:02
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: prateek-kumar-improving <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@currantw
currantw self-requested a review July 27, 2026 22:42
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed to 2c1ce7d.

Comment thread valkey_glide.stub.php
Comment thread valkey_glide_cluster.stub.php
Comment thread valkey_glide_commands.c Outdated
Comment thread valkey_glide_core_common.h Outdated
Comment thread tests/ValkeyGlideTest.php
Comment thread tests/ValkeyGlideTest.php Outdated
Comment thread tests/ValkeyGlideTest.php Outdated
Comment thread tests/ValkeyGlideTest.php
Comment thread valkey_glide_core_common.c Outdated
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Comment thread valkey_glide_commands.c
Comment thread valkey_glide_commands.c
Comment thread tests/start_valkey_with_replicas.sh
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: prateek-kumar-improving <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed to 6296505.

Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideTest.php Outdated
Comment thread valkey_glide.stub.php Outdated
Comment thread valkey_glide.stub.php Outdated
Comment thread valkey_glide.stub.php
Comment thread valkey_glide_core_common.c Outdated
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@Aryex Aryex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed to 100f017.

@currantw
currantw self-requested a review July 30, 2026 14:48

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just one remaining comment about possible duplicate tests

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed to 8ce99a9.
Looks good ✅
Thanks @prateek-kumar-improving 🎉

@prateek-kumar-improving
prateek-kumar-improving merged commit c2cfab8 into main Jul 30, 2026
38 of 40 checks passed
@prateek-kumar-improving
prateek-kumar-improving deleted the implement-migrate-command branch July 30, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants