From 49a2450e76488780987fbd247d2f3984899957b0 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 17 Mar 2015 14:54:13 -0700 Subject: Include the Sqlite schema to auto-init the database. --- netconf/SqliteNetworkConfigMaster.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'netconf/SqliteNetworkConfigMaster.cpp') diff --git a/netconf/SqliteNetworkConfigMaster.cpp b/netconf/SqliteNetworkConfigMaster.cpp index 8361a276..1dfb1a44 100644 --- a/netconf/SqliteNetworkConfigMaster.cpp +++ b/netconf/SqliteNetworkConfigMaster.cpp @@ -42,6 +42,9 @@ #include "../node/CertificateOfMembership.hpp" #include "../node/NetworkConfig.hpp" +// Include ZT_NETCONF_SCHEMA_SQL constant to init database +#include "netconf-schema.sql.c" + // Stored in database as schemaVersion key in Config. // If not present, database is assumed to be empty and at the current schema version // and this key/value is added automatically. @@ -52,13 +55,13 @@ namespace ZeroTier { SqliteNetworkConfigMaster::SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath) : _signingId(signingId), _dbPath(dbPath), - _db((sqlite3 *)0) + _db((sqlite3 *)0), _lock() { if (!_signingId.hasPrivate()) throw std::runtime_error("SqliteNetworkConfigMaster signing identity must have a private key"); - if (sqlite3_open_v2(dbPath,&_db,SQLITE_OPEN_READWRITE,(const char *)0) != SQLITE_OK) + if (sqlite3_open_v2(dbPath,&_db,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,(const char *)0) != SQLITE_OK) throw std::runtime_error("SqliteNetworkConfigMaster cannot open database file"); sqlite3_busy_timeout(_db,10000); } -- cgit v1.2.3