Refactoring legacy SQL to dbt

How does refactoring legacy SQL to dbt works if the legacy and new databases are different?