Feature/db migration fixes

this pull request is intended as ready to be merged.

by the way let's keep it open for some time to include all in one all the db fixes needed for partner-x production