Functional migration script