![]() |
Fledge
An open source edge computing platform for industrial users
|
Representation of an extension schema. More...
#include <schema.h>
Public Member Functions | |
Schema (const std::string &name, const std::string &service, int version, const std::string &definition) | |
Schema (sqlite3 *db, const rapidjson::Document &doc) | |
Constructor for a schema. More... | |
int | getVersion () |
std::string | getService () |
bool | upgrade (sqlite3 *db, const rapidjson::Document &doc, const std::string &definition) |
Upgrade an existing schema. More... | |
bool | attach (sqlite3 *db) |
Attach the schema to the database handle if not already attached. More... | |
Representation of an extension schema.
Each active schema has an instance of the class that is managed by the SchemaManager class. This is either created when Fledge restarts and reads the schema definition from the database or when a service requests an extension schema to be created.
The class is responsible for the creation and update of the extension schemas. The name, service, version and definition of each schema is written to a control table in the Fledge schema to allow for the versions to be tracked and also to allow the extension schemas to be attached.
Schema::Schema | ( | sqlite3 * | db, |
const rapidjson::Document & | doc | ||
) |
Constructor for a schema.
This is the case when a service has requested a schema that does not already exist. We must create a new schema from scratch.
db | SQLite3 database handle |
doc | JSON definition of the schema to create |
bool Schema::attach | ( | sqlite3 * | db | ) |
Attach the schema to the database handle if not already attached.
db | The database handle to attach the schema to |
bool Schema::upgrade | ( | sqlite3 * | db, |
const rapidjson::Document & | doc, | ||
const std::string & | definition | ||
) |
Upgrade an existing schema.
The upgrade process is limited and will only do the following operations; add a new table, drop a table, add a new column to a table, drop a column from a table, add a new index or drop an index.
db | The SQLite3 database connection |
doc | The pre-parsed version of the schema definition |
definition | The schema defintion for the new version of the schema as JSON |
bool | True if the upgrade suceeded. |