SelectoMix.ConfigMerger (selecto_mix v0.4.2)

Merges new schema introspection data with existing user customizations.

This module intelligently combines freshly introspected schema data with existing domain configurations, preserving user customizations while incorporating new fields, associations, and other schema changes.

The merger uses special markers in the generated files to identify sections that can be safely regenerated vs. sections that contain user customizations.

Summary

Functions

Generate a backup of the existing file before major changes.

Merge two configuration maps intelligently.

Merge new domain configuration with existing file content.

Parse an existing domain file to extract configuration and customizations.

Functions

create_backup_if_needed(file_path, existing_content, new_config)

Generate a backup of the existing file before major changes.

merge_configurations(new_config, existing_config)

Merge two configuration maps intelligently.

merge_with_existing(new_config, existing_content)

Merge new domain configuration with existing file content.

This function parses existing domain files to extract user customizations, then intelligently merges them with new schema data.

Strategy

  1. Parse existing file to identify custom vs. generated sections
  2. Extract user customizations (custom fields, filters, joins)
  3. Merge new schema fields while preserving customizations
  4. Generate backup of existing file if major changes detected

Returns

A merged configuration map that combines:

  • All new/changed fields from schema introspection
  • Preserved user customizations from existing file
  • Updated metadata and suggestions

parse_existing_config(file_content)

Parse an existing domain file to extract configuration and customizations.