1 /* 2 * Copyright (c) 2021 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 SQLITE_SINGLE_VER_SCHEMA_DATABASE_UPGRADER_H 17 #define SQLITE_SINGLE_VER_SCHEMA_DATABASE_UPGRADER_H 18 19 #include "sqlite_single_ver_database_upgrader.h" 20 #include "single_ver_schema_database_upgrader.h" 21 22 namespace DistributedDB { 23 class SQLiteSingleVerSchemaDatabaseUpgrader final : public SQLiteSingleVerDatabaseUpgrader, 24 public SingleVerSchemaDatabaseUpgrader { 25 public: 26 // An invalid SchemaObject indicate no schema 27 SQLiteSingleVerSchemaDatabaseUpgrader(sqlite3 *db, const SchemaObject &newSchema, 28 const SecurityOption &securityOpt, bool isMemDB); ~SQLiteSingleVerSchemaDatabaseUpgrader()29 ~SQLiteSingleVerSchemaDatabaseUpgrader() override {}; 30 protected: 31 // Get an empty string with return_code E_OK indicate no schema but everything normally 32 int GetDatabaseSchema(std::string &dbSchema) const override; 33 34 // Set or update schema into database file 35 int SetDatabaseSchema(const std::string &dbSchema) override; 36 37 int UpgradeValues() override; 38 int UpgradeIndexes(const IndexDifference &indexDiffer) override; 39 }; 40 } // namespace DistributedDB 41 #endif // SQLITE_SINGLE_VER_SCHEMA_DATABASE_UPGRADER_H