add refactor script

Add script to migrate the database rows.