CAPYSQUASH

Configuration Reference

Complete reference for capysquash-cli configuration options

CONFIGURATION REFERENCE

Comprehensive guide to configuring capysquash for your specific needs.

CONFIGURATION FILE

capysquash uses capysquash.config.json for configuration.

Generate Default Config

capysquash init-config

Creates capysquash.config.json with all available options and documentation.

CONFIGURATION STRUCTURE

{
  "safety_level": "standard",
  "output": {
    "format": "organized",
    "preserve_comments": true,
    "add_consolidation_comments": true,
    "directory": "squashed"
  },
  "rules": {
    "table_operations": {
      "consolidate_create_alter": true,
      "remove_drop_create_cycles": true,
      "preserve_data_operations": true
    },
    "function_operations": {
      "remove_duplicate_definitions": true,
      "preserve_signature_changes": false
    },
    "index_operations": {
      "consolidate_index_creation": true,
      "remove_redundant_indexes": false
    }
  },
  "performance": {
    "streaming_threshold_mb": 5,
    "parallel_processing": true,
    "show_progress": true,
    "memory_limit_mb": 256,
    "batch_size": 50,
    "worker_count": 0
  },
  "validation": {
    "docker_approach": "TWO_DATABASES",
    "enable_extension_detection": true,
    "auto_install_extensions": true,
    "enable_sql_fixes": true,
    "custom_extensions": {}
  },
  "modern_features": {
    "enable_vector_support": true,
    "enable_generated_columns": true,
    "enable_merge_statements": true,
    "enable_multirange_types": true
  },
  "third_party_integrations": {
    "supabase_integration": {
      "enabled": true,
      "enable_rls": true,
      "storage_integration": true,
      "auth_integration": true
    },
    "clerk_integration": {
      "enabled": false,
      "jwt_version": "v2"
    }
  },
  "postgresql_features": {
    "target_version": "16",
    "enable_partitioning": true,
    "enable_inheritance": true
  }
}

CONFIGURATION SECTIONS

Safety Level

Options: paranoid, conservative, standard, aggressive

Default: standard

{
  "safety_level": "standard"
}

See Safety Levels for detailed explanation.

Output Configuration

{
  "output": {
    // Organization format
    "format": "organized",  // "organized" | "single_file" | "by_category"

// Comment preservation "preserve_comments": true, "add_consolidation_comments": true,

// Output location "directory": "squashed",

// File naming "file_prefix": "", "file_suffix": "_squashed"


}
}

Options:

OptionTypeDefaultDescription
formatstring"organized"Output organization format
preserve_commentsbooleantrueKeep original comments
add_consolidation_commentsbooleantrueAdd consolidation metadata
directorystring"squashed"Output directory path
file_prefixstring""Prefix for output files
file_suffixstring"_squashed"Suffix for output files

Consolidation Rules

Table Operations

{
  "rules": {
    "table_operations": {
      "consolidate_create_alter": true,
      "remove_drop_create_cycles": true,
      "preserve_data_operations": true,
      "merge_column_additions": true,
      "optimize_constraints": true
    }
  }
}
OptionDefaultDescription
consolidate_create_altertrueMerge CREATE + ALTER sequences
remove_drop_create_cyclestrueEliminate redundant DROP/CREATE
preserve_data_operationstrueKeep INSERT/UPDATE/DELETE intact
merge_column_additionstrueCombine column additions
optimize_constraintstrueConsolidate constraints

Function Operations

{
  "rules": {
    "function_operations": {
      "remove_duplicate_definitions": true,
      "preserve_signature_changes": false,
      "consolidate_similar_functions": false
    }
  }
}

Index Operations

{
  "rules": {
    "index_operations": {
      "consolidate_index_creation": true,
      "remove_redundant_indexes": false,
      "optimize_index_order": true
    }
  }
}

Performance Configuration

{
  "performance": {
    // Streaming mode
    "streaming_threshold_mb": 5,
    "memory_limit_mb": 256,
    "batch_size": 50,

// Parallelization "parallel_processing": true, "worker_count": 0, // 0 = auto-detect

// Progress tracking "show_progress": true, "progress_update_interval_ms": 500


}
}

Auto-Detection:

  • worker_count: 0 → Uses runtime.NumCPU()
  • streaming_threshold_mb: 5 → Enables streaming above 5MB

Validation Configuration

{
  "validation": {
    // Docker validation approach
    "docker_approach": "TWO_DATABASES",  // "TWO_CONTAINERS" | "TWO_DATABASES" | "SCHEMA_DIFF"

    // Extension handling
    "enable_extension_detection": true,
    "auto_install_extensions": true,
    "custom_extensions": {
      "vector": "pgvector/pgvector:latest",
      "postgis": "postgis/postgis:latest"
    },

    // SQL fixes
    "enable_sql_fixes": true,
    "sql_fix_patterns": [
      "unsafe_to_safe",
      "modern_syntax"
    ]
  }
}

Docker Approaches:

ApproachSpeedAccuracyUse Case
TWO_CONTAINERSSlowHighestProduction
TWO_DATABASESMediumHighStandard
SCHEMA_DIFFFastGoodDevelopment

Modern PostgreSQL Features

{
  "modern_features": {
    "enable_vector_support": true,
    "enable_generated_columns": true,
    "enable_merge_statements": true,
    "enable_multirange_types": true,
    "enable_json_subscripting": true
  }
}

Third-Party Integrations

Supabase

{
  "third_party_integrations": {
    "supabase_integration": {
      "enabled": true,
      "enable_rls": true,
      "storage_integration": true,
      "auth_integration": true,
      "detect_supabase_auth_patterns": true
    }
  }
}

Clerk

{
  "third_party_integrations": {
    "clerk_integration": {
      "enabled": true,
      "jwt_version": "v2",
      "detect_organization_patterns": true
    }
  }
}

PostgreSQL Version Targeting

{
  "postgresql_features": {
    "target_version": "16",
    "enable_partitioning": true,
    "enable_inheritance": true,
    "strict_version_compliance": false
  }
}

ENVIRONMENT VARIABLES

Override configuration via environment variables:

# Safety level
export capysquash_SAFETY_LEVEL="conservative"

# Output directory

export capysquash\_OUTPUT\_DIR="clean\_migrations"

# Performance

export capysquash\_WORKER\_COUNT=8
export capysquash\_MEMORY\_LIMIT=512

# AI providers

export ANTHROPIC\_API\_KEY="sk-ant-..."
export OPENAI\_API\_KEY="sk-..."

COMMAND-LINE OVERRIDES

Command-line flags override config file:

# Override safety level
capysquash squash migrations/*.sql --safety=aggressive

# Override output
capysquash squash migrations/*.sql --output=custom/

# Override workers
capysquash squash migrations/*.sql --workers=16

CONFIGURATION EXAMPLES

Development Configuration

{
  "safety_level": "aggressive",
  "output": {
    "format": "single_file",
    "directory": "dev_clean"
  },
  "rules": {
    "table_operations": {
      "consolidate_create_alter": true,
      "remove_drop_create_cycles": true
    }
  },
  "performance": {
    "streaming_threshold_mb": 10,
    "parallel_processing": true,
    "show_progress": true
  },
  "validation": {
    "docker_approach": "SCHEMA_DIFF",
    "enable_sql_fixes": true
  }
}

Production Configuration

{
  "safety_level": "conservative",
  "output": {
    "format": "organized",
    "preserve_comments": true,
    "add_consolidation_comments": true,
    "directory": "production_migrations"
  },
  "rules": {
    "table_operations": {
      "consolidate_create_alter": true,
      "remove_drop_create_cycles": false,
      "preserve_data_operations": true
    },
    "function_operations": {
      "remove_duplicate_definitions": false
    }
  },
  "performance": {
    "streaming_threshold_mb": 5,
    "parallel_processing": false,
    "show_progress": true
  },
  "validation": {
    "docker_approach": "TWO_CONTAINERS",
    "enable_extension_detection": true,
    "auto_install_extensions": true
  }
}

CI/CD Configuration

{
  "safety_level": "standard",
  "output": {
    "format": "organized",
    "directory": "squashed"
  },
  "performance": {
    "streaming_threshold_mb": 5,
    "parallel_processing": true,
    "show_progress": false
  },
  "validation": {
    "docker_approach": "TWO_DATABASES",
    "enable_extension_detection": true
  }
}

CONFIGURATION PRECEDENCE

Configuration is loaded in this order (later overrides earlier):

  1. Default embedded configuration
  2. Config file (capysquash.config.json)
  3. Environment variables
  4. Command-line flags

TROUBLESHOOTING

Config Not Loading

# Verify config file exists
cat capysquash.config.json

# Check JSON syntax

jq . capysquash.config.json

# Use explicit path

capysquash squash migrations/\*.sql --config=./custom.config.json

Invalid Configuration

# Validate config
capysquash init-config --validate

# Reset to defaults
capysquash init-config --force

NEXT STEPS

How is this guide?

On this page