licensed, a bit better file handling, a bit better migration handling
This commit is contained in:
parent
319895db64
commit
03d7614673
28 changed files with 934 additions and 22 deletions
|
@ -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():
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue