fix: backfill utm_source from legacy source column on Lead/Opportunity#396
Open
dpk404 wants to merge 2 commits into
Open
fix: backfill utm_source from legacy source column on Lead/Opportunity#396dpk404 wants to merge 2 commits into
source column on Lead/Opportunity#396dpk404 wants to merge 2 commits into
Conversation
Ports frappe/erpnext#55022 so next_crm sites can recover orphaned source values without waiting on the upstream patch to land. The v15 `migrate_to_utm_analytics` patch renamed `source -> utm_source` on Lead and Opportunity via the `oldfieldname` schema hint. That hint is documentation-only — Frappe's DocField sync never issues a RENAME COLUMN based on it (only the desk-driven Custom Field rename flow does). So on every upgraded site, `utm_source` was added as an empty column and every row's data stayed on the legacy `source` column, where get_meta()-aware code can't see it. This patch: - Skips cleanly if either column is absent (clean rename or fresh site). - Copies legacy `source` -> `utm_source` for rows where utm is empty. - Leaves rows with both columns populated to *different* values untouched and reports a count for manual triage. - Idempotent — a second run is a no-op. Reports per-doctype row counts on stdout during `bench migrate`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of 7fc3f44 to
version-16-hotfixso the UTM-source backfill patch is available on the hotfix line.Adds
next_crm/patches/v1_0/backfill_utm_source_from_legacy_source.pyand registers it inpatches.txt(in addition to the existingv0_1.remove_stale_field_order_property_setterspatch that's already on the hotfix branch).Test plan
bench --site <site> migrateruns the patch without errorutm_sourceis populated for rows where it was previously NULL and the legacysourcecolumn had a value