33from typing import Optional
44
55from redisvl .cli .utils import add_redis_connection_options , create_redis_url
6- from redisvl .migration import MigrationExecutor , MigrationPlanner , MigrationValidator
6+ from redisvl .migration import (
7+ MigrationExecutor ,
8+ MigrationPlanner ,
9+ MigrationValidator ,
10+ MigrationWizard ,
11+ )
712from redisvl .migration .utils import (
813 detect_aof_enabled ,
914 estimate_disk_space ,
@@ -25,6 +30,7 @@ class Migrate:
2530 "Commands:" ,
2631 "\t helper Show migration guidance and supported capabilities" ,
2732 "\t list List all available indexes" ,
33+ "\t wizard Interactively build a migration plan and schema patch" ,
2834 "\t plan Generate a migration plan for a document-preserving drop/recreate migration" ,
2935 "\t apply Execute a reviewed drop/recreate migration plan" ,
3036 "\t estimate Estimate disk space required for a migration plan (dry-run, no mutations)" ,
@@ -84,6 +90,7 @@ def helper(self):
8490
8591Commands:
8692 rvl migrate list List all indexes
93+ rvl migrate wizard --index <name> Guided migration builder
8794 rvl migrate plan --index <name> --schema-patch <patch.yaml>
8895 rvl migrate apply --plan <plan.yaml>
8996 rvl migrate validate --plan <plan.yaml>"""
@@ -101,6 +108,58 @@ def list(self):
101108 for position , index_name in enumerate (indexes , start = 1 ):
102109 print (f"{ position } . { index_name } " )
103110
111+ def wizard (self ):
112+ parser = argparse .ArgumentParser (
113+ usage = (
114+ "rvl migrate wizard [--index <name>] "
115+ "[--patch <existing_patch.yaml>] "
116+ "[--plan-out <migration_plan.yaml>] [--patch-out <schema_patch.yaml>]"
117+ )
118+ )
119+ parser .add_argument ("-i" , "--index" , help = "Source index name" , required = False )
120+ parser .add_argument (
121+ "--patch" ,
122+ help = "Load an existing schema patch to continue editing" ,
123+ default = None ,
124+ )
125+ parser .add_argument (
126+ "--plan-out" ,
127+ help = "Path to write migration_plan.yaml" ,
128+ default = "migration_plan.yaml" ,
129+ )
130+ parser .add_argument (
131+ "--patch-out" ,
132+ help = "Path to write schema_patch.yaml (for later editing)" ,
133+ default = "schema_patch.yaml" ,
134+ )
135+ parser .add_argument (
136+ "--target-schema-out" ,
137+ help = "Optional path to write the merged target schema" ,
138+ default = None ,
139+ )
140+ parser .add_argument (
141+ "--key-sample-limit" ,
142+ help = "Maximum number of keys to sample from the index keyspace" ,
143+ type = int ,
144+ default = 10 ,
145+ )
146+ parser = add_redis_connection_options (parser )
147+ args = parser .parse_args (sys .argv [3 :])
148+
149+ redis_url = create_redis_url (args )
150+ wizard = MigrationWizard (
151+ planner = MigrationPlanner (key_sample_limit = args .key_sample_limit )
152+ )
153+ plan = wizard .run (
154+ index_name = args .index ,
155+ redis_url = redis_url ,
156+ existing_patch_path = args .patch ,
157+ plan_out = args .plan_out ,
158+ patch_out = args .patch_out ,
159+ target_schema_out = args .target_schema_out ,
160+ )
161+ self ._print_plan_summary (args .plan_out , plan )
162+
104163 def plan (self ):
105164 parser = argparse .ArgumentParser (
106165 usage = (
0 commit comments