1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef APP_DOMAIN_VERIFY_RDB_MIGRATE_MGR_H
17 #define APP_DOMAIN_VERIFY_RDB_MIGRATE_MGR_H
18 #include "app_domain_verify_rdb_config.h"
19 #include "rdb_errno.h"
20 #include "rdb_open_callback.h"
21 #include "app_domain_verify_rdb_data_manager.h"
22 #include "bundle_verify_status_info.h"
23 #include "rdb_store.h"
24 #include <functional>
25 namespace OHOS::AppDomainVerify {
26 using TransFunc = std::function<bool(NativeRdb::RdbStore& rdb)>;
27 class RdbMigrateMgr {
28 public:
29     RdbMigrateMgr(const AppDomainVerifyRdbConfig& appDomainVerifyRdbConfig);
30     int Upgrade(NativeRdb::RdbStore& rdbStore, int currVersion, int targetVersion);
31 
32 private:
33     AppDomainVerifyRdbConfig appDomainVerifyRdbConfig_;
34     int QueryInnerVersion(NativeRdb::RdbStore& store);
35     void UpgradeFromV1ToV2(NativeRdb::RdbStore& rdbStore);
36     int UpgradeFromV2ToV3(NativeRdb::RdbStore& rdbStore);
37     int ExecSqlWithTrans(NativeRdb::RdbStore& store, const TransFunc& func);
38 };
39 }
40 #endif  // APP_DOMAIN_VERIFY_RDB_MIGRATE_MGR_H
41