mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
remove unwanted table, fix nodestore table naming
This commit is contained in:
@@ -150,21 +150,6 @@ private:
|
||||
)SQL";
|
||||
|
||||
public:
|
||||
// In the MySQLDatabase constructor, after the mysql_real_connect call:
|
||||
|
||||
// Add this to the private section with other table definitions
|
||||
static constexpr auto CREATE_NODES_TABLE = R"SQL(
|
||||
CREATE TABLE IF NOT EXISTS nodes (
|
||||
id INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
public_key VARCHAR(64) NOT NULL,
|
||||
ledger_hash VARCHAR(64) NOT NULL,
|
||||
type VARCHAR(32) NOT NULL,
|
||||
data MEDIUMBLOB NOT NULL,
|
||||
UNIQUE INDEX idx_key_hash (public_key, ledger_hash)
|
||||
)
|
||||
)SQL";
|
||||
|
||||
// Then modify the constructor:
|
||||
MySQLDatabase(Application& app, Config const& config, JobQueue& jobQueue)
|
||||
: app_(app), useTxTables_(config.useTxTables())
|
||||
{
|
||||
@@ -190,11 +175,6 @@ public:
|
||||
mysql_error(mysql));
|
||||
|
||||
// Create schema tables
|
||||
if (mysql_query(mysql, CREATE_NODES_TABLE))
|
||||
throw std::runtime_error(
|
||||
std::string("Failed to create nodes table: ") +
|
||||
mysql_error(mysql));
|
||||
|
||||
if (mysql_query(mysql, CREATE_LEDGERS_TABLE))
|
||||
throw std::runtime_error(
|
||||
std::string("Failed to create ledgers table: ") +
|
||||
|
||||
@@ -230,11 +230,15 @@ public:
|
||||
{
|
||||
// Sanitize table name
|
||||
name_.erase(
|
||||
std::remove_if(
|
||||
std::unique(
|
||||
name_.begin(),
|
||||
name_.end(),
|
||||
[](char c) { return !std::isalnum(c); }),
|
||||
std::transform(
|
||||
name_.begin(),
|
||||
name_.end(),
|
||||
name_.begin(),
|
||||
[](char c) { return std::isalnum(c) ? c : '_'; })),
|
||||
name_.end());
|
||||
|
||||
name_ = "nodes_" + name_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user