1 /*
2  * Copyright (c) 2023 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 OHOS_CLOUD_SYNC_DATA_SYNCER_RDB_COL_H
17 #define OHOS_CLOUD_SYNC_DATA_SYNCER_RDB_COL_H
18 
19 #include <set>
20 #include <string>
21 
22 namespace OHOS {
23 namespace FileManagement {
24 namespace CloudSync {
25 /* basic */
26 const std::string DATA_SYNCER_ID = "dataSyncerId";
27 const std::string USER_ID = "userId";
28 const std::string BUNDLE_NAME = "bundleName";
29 const std::string SYNC_STATE = "syncState";
30 const std::string LAST_SYNC_TIME = "lastSyncTime";
31 const std::string DATA_SYNCER_UNIQUE_ID = "dataSyncerUniqueId";
32 
33 const std::string DATA_SYNCER_TABLE = "DataSyncers";
34 
35 const std::string DATA_SYNCER_UNIQUE_INDEX = "DataSyncersUniqueIndex";
36 
37 const std::string CREATE_DATA_SYNCER_TABLE = "CREATE TABLE IF NOT EXISTS " +
38     DATA_SYNCER_TABLE + " (" +
39     DATA_SYNCER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
40     USER_ID + " INT, " +
41     BUNDLE_NAME + " TEXT, " +
42     SYNC_STATE + " INT DEFAULT 0, " +
43     LAST_SYNC_TIME + " BIGINT DEFAULT 0, " +
44     DATA_SYNCER_UNIQUE_ID + " TEXT)";
45 
46 const std::string CREATE_DATA_SYNCER_UNIQUE_INDEX =
47         "CREATE UNIQUE INDEX IF NOT EXISTS " + DATA_SYNCER_UNIQUE_INDEX +
48         " ON " + DATA_SYNCER_TABLE + " (" + DATA_SYNCER_UNIQUE_ID + ")";
49 
50 const std::set<std::string> DATA_SYNCER_COL = {
51     DATA_SYNCER_ID, USER_ID, BUNDLE_NAME, SYNC_STATE, LAST_SYNC_TIME, DATA_SYNCER_UNIQUE_ID
52 };
53 
54 const std::string EL1_CLOUDFILE_DIR = "/data/service/el1/public/cloudfile";
55 const std::string DATA_SYNCER_DB = "DataSyncers.db";
56 
57 const int32_t CLOUD_DISK_RDB_VERSION = 2;
58 enum {
59     VERSION_ADD_DATA_SYNCER_UNIQUE_INDEX = 2,
60 };
61 } // namespace CloudSync
62 } // namespace FileManagement
63 } // namespace OHOS
64 #endif // OHOS_CLOUD_SYNC_DATA_SYNCER_RDB_COL_H
65