Fixes #4832: Add migration script to change the ids in database