How to write Dynamic migrations