Loading src/blogi.cpp +26 −16 Changes for src/blogi.cpp: 26 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -269,23 +269,27 @@ blogi::Blogi::Blogi(std::vector<netplus::socket*> serversocket,bool debug) : Htt Session sess(*initdb); sess._initSession(); dbpp::SQL optsql; dbpp::SQL optionsSql; dbpp::SQL themeColorsSql; dbpp::SQL alterSql; dbpp::DBResult optres; optsql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," optionsSql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optionsSql) << " PRIMARY KEY," << dbpp::quoteIdentifier(*initdb, "key") << " character varying(255) NOT NULL," << "value text NOT NULL);" << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," << "value text NOT NULL);"; themeColorsSql << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(themeColorsSql) << " PRIMARY KEY," << "profile character varying(32) NOT NULL," << "variable character varying(64) NOT NULL," << "value character varying(64) NOT NULL);"; dbpp::modifyColumn(optsql, *initdb, "options", "value", "text", "NOT NULL"); dbpp::modifyColumn(alterSql, *initdb, "options", "value", "text", "NOT NULL"); try { initdb->exec(optsql, optres); initdb->exec(optionsSql, optres); initdb->exec(themeColorsSql, optres); initdb->exec(alterSql, optres); } catch(std::runtime_error &e) { std::cerr << e.what() << std::endl; return; Loading Loading @@ -397,19 +401,25 @@ bool blogi::Blogi::reloadConfig() { Session sess(*initdb); sess._initSession(); dbpp::SQL optsql; dbpp::SQL optionsSql; dbpp::SQL themeColorsSql; dbpp::SQL alterSql; dbpp::DBResult optres; optsql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," optionsSql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optionsSql) << " PRIMARY KEY," << dbpp::quoteIdentifier(*initdb, "key") << " character varying(255) NOT NULL," << "value text NOT NULL);" << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," << "value text NOT NULL);"; themeColorsSql << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(themeColorsSql) << " PRIMARY KEY," << "profile character varying(32) NOT NULL," << "variable character varying(64) NOT NULL," << "value character varying(64) NOT NULL);"; dbpp::modifyColumn(optsql, *initdb, "options", "value", "text", "NOT NULL"); try { initdb->exec(optsql, optres); } catch (std::runtime_error &e) { dbpp::modifyColumn(alterSql, *initdb, "options", "value", "text", "NOT NULL"); try { initdb->exec(optionsSql, optres); initdb->exec(themeColorsSql, optres); initdb->exec(alterSql, optres); } catch (std::runtime_error &e) { std::cerr << "[blogi] Reload: DB init failed for '" << dcfg.names[0] << "': " << e.what() << std::endl; } Loading Loading
src/blogi.cpp +26 −16 Changes for src/blogi.cpp: 26 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -269,23 +269,27 @@ blogi::Blogi::Blogi(std::vector<netplus::socket*> serversocket,bool debug) : Htt Session sess(*initdb); sess._initSession(); dbpp::SQL optsql; dbpp::SQL optionsSql; dbpp::SQL themeColorsSql; dbpp::SQL alterSql; dbpp::DBResult optres; optsql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," optionsSql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optionsSql) << " PRIMARY KEY," << dbpp::quoteIdentifier(*initdb, "key") << " character varying(255) NOT NULL," << "value text NOT NULL);" << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," << "value text NOT NULL);"; themeColorsSql << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(themeColorsSql) << " PRIMARY KEY," << "profile character varying(32) NOT NULL," << "variable character varying(64) NOT NULL," << "value character varying(64) NOT NULL);"; dbpp::modifyColumn(optsql, *initdb, "options", "value", "text", "NOT NULL"); dbpp::modifyColumn(alterSql, *initdb, "options", "value", "text", "NOT NULL"); try { initdb->exec(optsql, optres); initdb->exec(optionsSql, optres); initdb->exec(themeColorsSql, optres); initdb->exec(alterSql, optres); } catch(std::runtime_error &e) { std::cerr << e.what() << std::endl; return; Loading Loading @@ -397,19 +401,25 @@ bool blogi::Blogi::reloadConfig() { Session sess(*initdb); sess._initSession(); dbpp::SQL optsql; dbpp::SQL optionsSql; dbpp::SQL themeColorsSql; dbpp::SQL alterSql; dbpp::DBResult optres; optsql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," optionsSql << "CREATE TABLE IF NOT EXISTS options (" << "id " << initdb->getUUIDType(optionsSql) << " PRIMARY KEY," << dbpp::quoteIdentifier(*initdb, "key") << " character varying(255) NOT NULL," << "value text NOT NULL);" << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(optsql) << " PRIMARY KEY," << "value text NOT NULL);"; themeColorsSql << "CREATE TABLE IF NOT EXISTS theme_colors (" << "id " << initdb->getUUIDType(themeColorsSql) << " PRIMARY KEY," << "profile character varying(32) NOT NULL," << "variable character varying(64) NOT NULL," << "value character varying(64) NOT NULL);"; dbpp::modifyColumn(optsql, *initdb, "options", "value", "text", "NOT NULL"); try { initdb->exec(optsql, optres); } catch (std::runtime_error &e) { dbpp::modifyColumn(alterSql, *initdb, "options", "value", "text", "NOT NULL"); try { initdb->exec(optionsSql, optres); initdb->exec(themeColorsSql, optres); initdb->exec(alterSql, optres); } catch (std::runtime_error &e) { std::cerr << "[blogi] Reload: DB init failed for '" << dcfg.names[0] << "': " << e.what() << std::endl; } Loading