1 /*
2  * Copyright (c) 2022 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 COLLABORATION_LOG_TABLE_MANAGER_H
17 #define COLLABORATION_LOG_TABLE_MANAGER_H
18 #include "sqlite_log_table_manager.h"
19 
20 namespace DistributedDB {
21 class CollaborationLogTableManager : public SqliteLogTableManager {
22 public:
23     CollaborationLogTableManager() = default;
24     ~CollaborationLogTableManager() override = default;
25 
26     std::string CalcPrimaryKeyHash(const std::string &references, const TableInfo &table,
27         const std::string &identity) override;
28 
29 private:
30     bool IsCollaborationWithoutKey(const TableInfo &table);
31 
32     std::string GetPrimaryKeySql(const TableInfo &table) override;
33     void GetIndexSql(const TableInfo &table, std::vector<std::string> &schema) override;
34 
35     std::string GetInsertTrigger(const TableInfo &table, const std::string &identity) override;
36     std::string GetUpdateTrigger(const TableInfo &table, const std::string &identity) override;
37     std::string GetDeleteTrigger(const TableInfo &table, const std::string &identity) override;
38     std::vector<std::string> GetDropTriggers(const TableInfo &table) override;
39 };
40 }
41 #endif // COLLABORATION_LOG_TABLE_MANAGER_H