Skip to main content
API migrations are a common task in large codebases. Whether you’re updating a deprecated function, changing parameter names, or modifying return types, Codegen makes it easy to update all call sites consistently.

Common Migration Scenarios

Renaming Parameters

When updating parameter names across an API, you need to update both the function definition and all call sites:
See dependencies and usages for more on updating parameter names and types.

Adding Required Parameters

When adding a new required parameter to an API:
See function calls and callsites for more on handling call sites.

Changing Parameter Types

When updating parameter types:
See working with type annotations for more on changing parameter types.

Deprecating Functions

When deprecating an old API in favor of a new one:

Bulk Updates to Method Chains

When updating chained method calls, like database queries or builder patterns:

Handling Breaking Changes

When making breaking changes to an API, it’s important to:
  1. Identify all affected call sites
  2. Make changes consistently
  3. Update related documentation
  4. Consider backward compatibility
Here’s a comprehensive example:

Best Practices

  1. Analyze First: Before making changes, analyze all call sites to understand usage patterns
  2. Make Atomic Changes: Update one aspect at a time
  3. Maintain Backwards Compatibility:
  4. Document Changes:
Remember to test thoroughly after making bulk changes to APIs. While Codegen ensures syntactic correctness, you’ll want to verify the semantic correctness of the changes.