diff --git a/engine/migrations/migration_helper.cc b/engine/migrations/migration_helper.cc index 28c560f9e..42cc8d453 100644 --- a/engine/migrations/migration_helper.cc +++ b/engine/migrations/migration_helper.cc @@ -7,15 +7,10 @@ cpp::result MigrationHelper::BackupDatabase( try { SQLite::Database src_db(src_db_path, SQLite::OPEN_READONLY); sqlite3* backup_db; -#if defined(_WIN32) - if (sqlite3_open16(backup_db_path.c_str(), &backup_db) != SQLITE_OK) { - throw std::runtime_error("Failed to open backup database"); - } -#else + if (sqlite3_open(backup_db_path.c_str(), &backup_db) != SQLITE_OK) { throw std::runtime_error("Failed to open backup database"); } -#endif sqlite3_backup* backup = sqlite3_backup_init(backup_db, "main", src_db.getHandle(), "main"); diff --git a/engine/migrations/migration_manager.cc b/engine/migrations/migration_manager.cc index f4b4f8046..2c2b6ddfd 100644 --- a/engine/migrations/migration_manager.cc +++ b/engine/migrations/migration_manager.cc @@ -4,6 +4,7 @@ #include "schema_version.h" #include "utils/file_manager_utils.h" #include "utils/scope_exit.h" +#include "utils/widechar_conv.h" namespace cortex::migr { @@ -40,7 +41,13 @@ cpp::result MigrationManager::Migrate() { if (std::filesystem::exists(fmu::GetCortexDataPath() / kCortexDb)) { auto src_db_path = (fmu::GetCortexDataPath() / kCortexDb); auto backup_db_path = (fmu::GetCortexDataPath() / kCortexDbBackup); - if (auto res = mgr_helper_.BackupDatabase(src_db_path, backup_db_path.string()); +#if defined(_WIN32) + if (auto res = mgr_helper_.BackupDatabase( + src_db_path, cortex::wc::WstringToUtf8(backup_db_path.wstring())); +#else + if (auto res = + mgr_helper_.BackupDatabase(src_db_path, backup_db_path.string()); +#endif res.has_error()) { CTL_INF("Error: backup database failed!"); return res;