mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 17:58:20 +00:00
c13937bd1f
* Properly store BBB in database
Store the BBB data in the database as the received SD0 packet as opposed to just the raw lxfml. Addressed several memory leaks as well.
* Add Sd0Conversion
Add brick by brick conversion commands with 2 parameters to tell the program what to do with the data.
Add zlib -> sd0 conversion. Files look good at a glance but should be tested in game to ensure stability. Tests to come.
* moving to laptop
ignore this commit. I need to move this to my laptop
* Add functionality to delete bad models
Adds functionality to delete bad models. Models are batched together and deleted in one commit.
More testing is needed to ensure data safety. Positive tests on a live database reveal the broken models were truncated and complete ones were kept around successfully. Tests should be done to ensure larger sd0 models are properly saved and not truncated since this command should be able to be run any time.
Valgrind tests need to be run as well to ensure no memory leaks exist.
* Delete from query change
Changed from delete to delete cascade and instead deleting from properties_contents as opposed to ugc.
* Address numerous bugs
DELETE CASCADE is not a valid SQL command so this was changed to a better delete statement.
Added user confirmation before deleting a broken model.
Address appending the string model appending bad data, causing excess deletion.
Addressed memory leaks with sql::Blob
* Error handling for string
* Even more proper handling...
* Add bounds check for cli command
Output a message if a bad command is used.
Update MasterServer.cpp
* Remove user interference
-Add back in mariadb build jobs so i dont nuke others systems
- Remove all user interference and consolidate work into one command since 1 depends on the next.
* Add comments
test
Revert "test"
This reverts commit fb831f268b7a2f0ccd20595aff64902ab4f4b4ee.
* Update CMakeMariaDBLists.txt
Test
* Improve migration runner
Migration runner now runs automatically.
- Resolved an issue where extremely large sql queries caused the database to go into an invalid state.
- Made migrations run automatically on server start.
- Resolved a tiny memory leak in migration runner? (discarded returned pointer)
- Moved sd0 migrations of brick models to be run automatically with migration runner.
- Created dummy file to tell when brick migrations have been run.
* Update README
Updated the README to reflect the new server migration state.
* Make model deleter actually delete models
My complicated sql actually did nothing... Tested that this new SQL properly gets rid of bad data.
* Revert "Update CMakeMariaDBLists.txt"
This reverts commit 8b859d8529
.
32 lines
956 B
C++
32 lines
956 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <conncpp.hpp>
|
|
|
|
class MySqlException : public std::runtime_error {
|
|
public:
|
|
MySqlException() : std::runtime_error("MySQL error!") {}
|
|
MySqlException(const std::string& msg) : std::runtime_error(msg.c_str()) {}
|
|
};
|
|
|
|
class Database {
|
|
private:
|
|
static sql::Driver* driver;
|
|
static sql::Connection* con;
|
|
static sql::Properties props;
|
|
static std::string database;
|
|
public:
|
|
static void Connect(const std::string& host, const std::string& database, const std::string& username, const std::string& password);
|
|
static void Connect();
|
|
static void Destroy(std::string source = "", bool log = true);
|
|
|
|
static sql::Statement* CreateStmt();
|
|
static sql::PreparedStatement* CreatePreppedStmt(const std::string& query);
|
|
static void Commit();
|
|
static bool GetAutoCommit();
|
|
static void SetAutoCommit(bool value);
|
|
|
|
static std::string GetDatabase() { return database; }
|
|
static sql::Properties GetProperties() { return props; }
|
|
};
|