Skip to content

fix: register both after_migrate hooks so bf_contract custom field is created - #11

Merged
skibanga merged 1 commit into
masterfrom
fix/after-migrate-custom-fields
Oct 2, 2026
Merged

skibanga merged 1 commit into
masterfrom
fix/after-migrate-custom-fields

Conversation

@skibanga

@skibanga skibanga commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

On production, opening a BF Contract fails:

pymysql.err.OperationalError: (1054, "Unknown column 'tabSales Invoice.bf_contract' in 'WHERE'")

hooks.py assigned after_migrate two times. The second assignment replaced the first. Because of this, consms.custom_fields.create_custom_fields did not run on migrate, and the bf_contract custom field was not created on Sales Invoice. The BF Contract dashboard counts linked Sales Invoices by bf_contract, so the query fails.

Fix

Merge the two hooks into one list, so that both functions run:

after_migrate = [
	"consms.custom_fields.create_custom_fields",
	"consms.setup.after_migrate",
]

Both functions use Frappe's create_custom_fields. It is safe to run them again on sites that already have the fields.

After merge

Run bench --site <site> migrate on each site that has consms installed.

🤖 Generated with Claude Code

… created

hooks.py assigned after_migrate twice. The second assignment replaced the
first, so consms.custom_fields.create_custom_fields never ran. Sales Invoice
had no bf_contract field, and the BF Contract dashboard failed with
"Unknown column 'tabSales Invoice.bf_contract'".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skibanga
skibanga merged commit d05cd3d into master Oct 2, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant