Fixed MigrationManager to use queries and charset settings

Before this PR more advanced migrations might fail or cause data issues when specific database configuration was used.

Mainly custom charset or collation.