Frappe — Bake Customizations
Move live-database Custom Fields and Property Setters into the codebase so they survive bench migrate on fresh installs, are version-controlled, and no longer depend on ad-hoc DB state.
Quick start
Fetch customizations:
BENCH=$(pwd) PYTHON="$BENCH/env/bin/python" SCRIPT=$(find "$BENCH" -path "*/frappe-customizations-baker/scripts/fetch_customizations.py" | head -1) "$PYTHON" "$SCRIPT" --app <app_name>Choose baking target based on app ownership:
- Same-app → Use
frappe-doctype-schema(native field) - Different-app → Use
frappe-customizations-writer(sync_on_migrate custom/ file)
- Same-app → Use
Generate cleanup patch to delete DB records after baking
Workflows
Primary workflow: Bake customizations
Context: User requests customizations from DB → code (e.g. "persist field customizations", "bake in Employee fields").
Steps:
- Fetch customizations via bundled script
- Filter/validate candidates (skip custom doctypes, handle duplicates)
- Initiate
frappe-doctype-schemaorfrappe-customizations-writerfor each DocType group - Draft cleanup patches (one per app) to delete now-redundant DB records
- Run
bench migrateto apply DB changes
Feature workflow: Ensure all necessary fields are baked in
Context: User is developing a feature and asks to ensure all required fields are baked in.
Steps:
- Build a feature field map by reading code and listing
(DocType, fieldname, usage location). - Check whether each field is already defined in code (
doctype/*.jsonorcustom/*.json). - For missing fields only, run a targeted search in dev DB customizations and continue with the bake plan.
- If missing fields exist in DB customizations, continue from the detailed workflow (analysis -> bake -> cleanup patch).
- If no matching DB customizations exist, proceed only with Step 3 of the detailed workflow (define fields in code), then continue the feature plan.
Advanced features
See REFERENCE.md for:
- Mental model:
doctype_appvscustomization_appdistinction - Detailed step-by-step workflow with edge cases
- Feature field-map workflow for feature development
- Decision tree for filtering candidates
- Common pitfalls (blank modules, Property Setter quirks,
default_print_format)