Skip to content

Safer install/migrate bootstrap: index fixes, multi-root handling, and validation improvements#61

Merged
Sendipad merged 7 commits intodevelopfrom
codex/analyze-codebase-for-bugs-and-propose-fixes
Mar 2, 2026
Merged

Safer install/migrate bootstrap: index fixes, multi-root handling, and validation improvements#61
Sendipad merged 7 commits intodevelopfrom
codex/analyze-codebase-for-bugs-and-propose-fixes

Conversation

@Sendipad
Copy link
Copy Markdown
Owner

@Sendipad Sendipad commented Mar 2, 2026

Motivation

  • Prevent runtime and migration issues by moving DDL to migrate/patch flows and making bootstrap idempotent and defensive.
  • Fix incorrect index column choices and fragile SQL generation that caused failed index creation on medium/large ledgers.
  • Avoid creating erroneous single-root assumptions for Party Master when setup templates may intentionally create multiple roots.
  • Harden settings validation to provide clearer errors and avoid frappe.get_meta() misuse.

Description

  • Add docs/codebase_audit.md with audit notes and recommendations about which bootstraps belong to migrate vs install flows.
  • Introduce include_schema_ddl flag to _safe_setup_operations() and call it with False from install paths and True from on_migrate() to ensure create_custom_indices() runs only during migrate/patch flows.
  • Restrict create_gender_fixtures() to test or developer mode by checking frappe.flags.in_test or frappe.conf.get("developer_mode").
  • Correct index definitions in create_custom_indices() to use customer for Sales Invoice and supplier for Purchase Invoice, verify existence of all referenced columns, quote column names in generated DDL, and log errors on failure.
  • Make create_party_master_tree() tolerant of multi-root setups by only bootstrapping a fallback root when no roots exist and normalize an existing 1000 record when present.
  • Improve PartyMasterSettings.validate_document_types() to require document_type with a row-specific error message and streamline parent/child validation logic.

Testing

  • Ran the project's automated test suite (bench run-tests / unit tests) and the tests completed successfully.
  • Executed a migration/install smoke path against a local test site to validate that DDL is skipped during install and executed during migrate, which succeeded.
  • Verified linters/type checks and basic runtime flows for Party Master creation and index creation logging, all of which passed.

@Sendipad Sendipad merged commit f4acca6 into develop Mar 2, 2026
6 checks passed
@Sendipad Sendipad deleted the codex/analyze-codebase-for-bugs-and-propose-fixes branch March 2, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant