Skip to content

Commit 7eea293

Browse files
committed
fix: address review round 3 for migrate-wizard (#564)
- Remove queued updates/renames when a field is deleted - Apply index-level changes (name, prefix) in staged preview schema - Merge duplicate updates for the same field instead of appending
1 parent 8db2f90 commit 7eea293

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

redisvl/migration/wizard.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ def _apply_staged_changes(
170170
for added in changes.add_fields:
171171
working["fields"].append(added)
172172

173+
# Apply index-level changes (name, prefix) so preview reflects them
174+
if changes.index:
175+
for key, value in changes.index.items():
176+
working["index"][key] = value
177+
173178
return working
174179

175180
def _build_patch(
@@ -215,7 +220,18 @@ def _build_patch(
215220
)
216221
update = self._prompt_update_field(update_schema)
217222
if update:
218-
changes.update_fields.append(update)
223+
# Merge with existing update for same field if present
224+
existing = next(
225+
(u for u in changes.update_fields if u.name == update.name),
226+
None,
227+
)
228+
if existing:
229+
if update.attrs:
230+
existing.attrs = {**(existing.attrs or {}), **update.attrs}
231+
if update.type:
232+
existing.type = update.type
233+
else:
234+
changes.update_fields.append(update)
219235
elif action == "3":
220236
field_name = self._prompt_remove_field(working_schema)
221237
if field_name:
@@ -229,6 +245,13 @@ def _build_patch(
229245
print(f"Cancelled staged addition of '{field_name}'.")
230246
else:
231247
changes.remove_fields.append(field_name)
248+
# Also remove any queued updates or renames for this field
249+
changes.update_fields = [
250+
u for u in changes.update_fields if u.name != field_name
251+
]
252+
changes.rename_fields = [
253+
r for r in changes.rename_fields if r.old_name != field_name
254+
]
232255
elif action == "4":
233256
# Filter out staged additions from rename candidates
234257
staged_add_names = {f["name"] for f in changes.add_fields}

0 commit comments

Comments
 (0)