सामग्री पर जाएँ
दस्तावेज़

Schema Diff

Side-by-side schema shape comparator जो एक idempotent mongosh migration script emit करता है। PR gate के रूप में या एक major refactor से पहले उपयोगी।

यह क्या है

एक workspace tab जो दो schema shapes की तुलना करता है (JSON paste करें या live connection से sample करें) और differences को एक side-by-side panel में render करता है। Migration tab एक mongosh script emit करता है जिसे आप target पर match करने के लिए चला सकते हैं — re-run करने के लिए सुरक्षित क्योंकि हर step idempotent है।

कब उपयोग करें

PR gate के रूप में wire करें ताकि एक teammate generated migration plan के बिना schema change land न कर सके। Major refactor से पहले चलाएँ यह देखने के लिए कि branches के बीच कौन से fields और types भिन्न हैं। Refresh के बाद चलाएँ यह पुष्टि करने के लिए कि dev / staging production से match करता है।

इसे कैसे खोलें

  1. NoSqlStudio desktop ऐप में, Tools menu → Schema Diff खोलें, या Ctrl+Alt+Shift+D दबाएँ।
  2. Workspace शीर्ष पर दो paste areas (Source और Target), बीच में एक diff panel, और नीचे Migration tab के साथ खुलता है।
  3. दो schema shapes paste करें (sample documents भी काम करते हैं — engine shape infer करता है) और Compare पर क्लिक करें।

Workflow

  1. Source — desired schema shape paste करें (आमतौर पर production sample या refactor के बाद target)।
  2. Target — receiving cluster (dev या staging) पर current shape paste करें।
  3. Diff — engine added fields (हरा), removed fields (लाल), और type changes (पीला) render करता है। Actual field path और inferred BSON type देखने के लिए किसी भी row पर क्लिक करें।
  4. Migration — Migration tab पर switch करें। Engine index changes के लिए $set/$unset/$rename + collMod का उपयोग करते हुए एक mongosh script emit करता है। Script idempotent है — पहले से converge किए target पर इसे चलाना no-op है।
  5. Script copy या download करें। Target पर mongosh से इसे चलाएँ, फिर Compare को re-run करें यह पुष्टि करने के लिए कि diff खाली है।

सीमाएँ (v1)

  • Inference sample-based है। यदि आपके schema में rare branches हैं जो sample में नहीं आईं, engine उन्हें miss करता है — representative documents cover करने के लिए sample size सेट करें।
  • Migration script fields और indexes handle करता है; यह views, search indexes, या time-series collections handle नहीं करता। उन्हें अलग से wire करें।
  • कोई transactional guarantee नहीं — generated script हर step को independently चलाता है। Multi-document consistency के लिए आपको इसे एक session.startTransaction block में स्वयं wrap करना होगा।