#842 Fixed migration script for already existing tables