Fledge
An open source edge computing platform for industrial users
Schema Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Schema()

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.

Parameters
dbSQLite3 database handle
docJSON definition of the schema to create

Member Function Documentation

◆ attach()

bool Schema::attach ( sqlite3 *  db)

Attach the schema to the database handle if not already attached.

Parameters
dbThe database handle to attach the schema to
Returns
bool True if the schema was attached

◆ upgrade()

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.

Parameters
dbThe SQLite3 database connection
docThe pre-parsed version of the schema definition
definitionThe schema defintion for the new version of the schema as JSON
boolTrue if the upgrade suceeded.

The documentation for this class was generated from the following files: