licensed, a bit better file handling, a bit better migration handling

This commit is contained in:
Blue 2023-12-10 20:23:15 -03:00
parent 319895db64
commit 03d7614673
Signed by: blue
GPG key ID: 9B203B252A63EE38
28 changed files with 934 additions and 22 deletions

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "router.h"
Router::Router():

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <map>

View file

@ -1,5 +1,10 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "server.h"
constexpr uint8_t currentDbVesion = 1;
Server::Server():
terminating(false),
requestCount(0),
@ -25,16 +30,8 @@ Server::Server():
std::cerr << "Couldn't connect to the database: " << e.what() << std::endl;
}
if (connected) {
uint8_t version = db->getVersion();
std::cout << "Database version is " << std::to_string(version) << std::endl;
if (version == 0) {
db->executeFile("database/migrations/m0.sql");
std::cout << "Successfully migrated to version 1" << std::endl;
db->setVersion(1);
std::cout << "Database version is " << std::to_string(db->getVersion()) << " now" << std::endl;
}
}
if (connected)
db->migrate(currentDbVesion);
router.addRoute("info", Server::info);
router.addRoute("env", Server::printEnvironment);

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <iostream>