Migrates database