mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
Don't lock tables by default; move tables around in schema; add peq-dump.sh script
This commit is contained in:
parent
bfecd6ad14
commit
53be04c39c
@ -255,6 +255,10 @@ void DatabaseDumpService::Dump()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsDumpDropTableSyntaxOnly()) {
|
||||||
|
SetDumpOutputToConsole(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (IsDumpOutputToConsole()) {
|
if (IsDumpOutputToConsole()) {
|
||||||
LogSys.SilenceConsoleLogging();
|
LogSys.SilenceConsoleLogging();
|
||||||
}
|
}
|
||||||
@ -278,7 +282,7 @@ void DatabaseDumpService::Dump()
|
|||||||
options += " --no-data";
|
options += " --no-data";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDumpNoTableLock()) {
|
if (!IsDumpTableLock()) {
|
||||||
options += " --skip-lock-tables";
|
options += " --skip-lock-tables";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,9 +340,22 @@ void DatabaseDumpService::Dump()
|
|||||||
FileUtil::mkdir(GetSetDumpPath());
|
FileUtil::mkdir(GetSetDumpPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string execution_result = execute(execute_command, IsDumpOutputToConsole());
|
if (IsDumpDropTableSyntaxOnly()) {
|
||||||
if (!execution_result.empty()) {
|
std::vector<std::string> tables = SplitString(tables_to_dump, ' ');
|
||||||
std::cout << execution_result;
|
|
||||||
|
for (auto &table : tables) {
|
||||||
|
std::cout << "DROP TABLE `" << table << "`;" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tables_to_dump.empty()) {
|
||||||
|
std::cerr << "No tables were specified" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::string execution_result = execute(execute_command, IsDumpOutputToConsole());
|
||||||
|
if (!execution_result.empty()) {
|
||||||
|
std::cout << execution_result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tables_to_dump.empty()) {
|
if (!tables_to_dump.empty()) {
|
||||||
@ -439,14 +456,15 @@ void DatabaseDumpService::SetDumpAllTables(bool dump_all_tables)
|
|||||||
{
|
{
|
||||||
DatabaseDumpService::dump_all_tables = dump_all_tables;
|
DatabaseDumpService::dump_all_tables = dump_all_tables;
|
||||||
}
|
}
|
||||||
bool DatabaseDumpService::IsDumpNoTableLock() const
|
|
||||||
|
bool DatabaseDumpService::IsDumpTableLock() const
|
||||||
{
|
{
|
||||||
return dump_no_table_lock;
|
return dump_table_lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpNoTableLock(bool dump_no_table_lock)
|
void DatabaseDumpService::SetDumpTableLock(bool dump_table_lock)
|
||||||
{
|
{
|
||||||
DatabaseDumpService::dump_no_table_lock = dump_no_table_lock;
|
DatabaseDumpService::dump_table_lock = dump_table_lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpWithCompression() const
|
bool DatabaseDumpService::IsDumpWithCompression() const
|
||||||
@ -498,3 +516,13 @@ void DatabaseDumpService::SetDumpOutputToConsole(bool dump_output_to_console)
|
|||||||
{
|
{
|
||||||
DatabaseDumpService::dump_output_to_console = dump_output_to_console;
|
DatabaseDumpService::dump_output_to_console = dump_output_to_console;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DatabaseDumpService::IsDumpDropTableSyntaxOnly() const
|
||||||
|
{
|
||||||
|
return dump_drop_table_syntax_only;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DatabaseDumpService::SetDumpDropTableSyntaxOnly(bool dump_drop_table_syntax_only)
|
||||||
|
{
|
||||||
|
DatabaseDumpService::dump_drop_table_syntax_only = dump_drop_table_syntax_only;
|
||||||
|
}
|
||||||
|
|||||||
@ -37,8 +37,8 @@ public:
|
|||||||
void SetDumpPlayerTables(bool dump_player_tables);
|
void SetDumpPlayerTables(bool dump_player_tables);
|
||||||
bool IsDumpLoginServerTables() const;
|
bool IsDumpLoginServerTables() const;
|
||||||
void SetDumpLoginServerTables(bool dump_login_server_tables);
|
void SetDumpLoginServerTables(bool dump_login_server_tables);
|
||||||
bool IsDumpNoTableLock() const;
|
bool IsDumpTableLock() const;
|
||||||
void SetDumpNoTableLock(bool dump_no_table_lock);
|
void SetDumpTableLock(bool dump_table_lock);
|
||||||
bool IsDumpWithCompression() const;
|
bool IsDumpWithCompression() const;
|
||||||
void SetDumpWithCompression(bool dump_with_compression);
|
void SetDumpWithCompression(bool dump_with_compression);
|
||||||
const std::string &GetDumpPath() const;
|
const std::string &GetDumpPath() const;
|
||||||
@ -49,18 +49,21 @@ public:
|
|||||||
void SetDumpQueryServerTables(bool dump_query_server_tables);
|
void SetDumpQueryServerTables(bool dump_query_server_tables);
|
||||||
bool IsDumpOutputToConsole() const;
|
bool IsDumpOutputToConsole() const;
|
||||||
void SetDumpOutputToConsole(bool dump_output_to_console);
|
void SetDumpOutputToConsole(bool dump_output_to_console);
|
||||||
|
bool IsDumpDropTableSyntaxOnly() const;
|
||||||
|
void SetDumpDropTableSyntaxOnly(bool dump_drop_table_syntax_only);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool dump_all_tables = false;
|
bool dump_all_tables = false;
|
||||||
bool dump_system_tables = false;
|
bool dump_system_tables = false;
|
||||||
bool dump_content_tables = false;
|
bool dump_content_tables = false;
|
||||||
bool dump_player_tables = false;
|
bool dump_player_tables = false;
|
||||||
bool dump_query_server_tables = false;
|
bool dump_query_server_tables = false;
|
||||||
bool dump_login_server_tables = false;
|
bool dump_login_server_tables = false;
|
||||||
bool dump_with_no_data = false;
|
bool dump_with_no_data = false;
|
||||||
bool dump_no_table_lock = false;
|
bool dump_table_lock = false;
|
||||||
bool dump_with_compression = false;
|
bool dump_with_compression = false;
|
||||||
bool dump_output_to_console = false;
|
bool dump_output_to_console = false;
|
||||||
|
bool dump_drop_table_syntax_only = false;
|
||||||
std::string dump_path;
|
std::string dump_path;
|
||||||
std::string dump_file_name;
|
std::string dump_file_name;
|
||||||
|
|
||||||
|
|||||||
@ -85,7 +85,8 @@ namespace DatabaseSchema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all player and meta-data tables
|
* @description Gets all player and meta-data tables
|
||||||
|
* @note These tables have no content in the PEQ daily dump
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -98,6 +99,8 @@ namespace DatabaseSchema {
|
|||||||
"account_rewards",
|
"account_rewards",
|
||||||
"adventure_details",
|
"adventure_details",
|
||||||
"adventure_stats",
|
"adventure_stats",
|
||||||
|
"bugs",
|
||||||
|
"bug_reports",
|
||||||
"buyer",
|
"buyer",
|
||||||
"char_recipe_list",
|
"char_recipe_list",
|
||||||
"character_activities",
|
"character_activities",
|
||||||
@ -129,6 +132,8 @@ namespace DatabaseSchema {
|
|||||||
"character_tribute",
|
"character_tribute",
|
||||||
"completed_tasks",
|
"completed_tasks",
|
||||||
"data_buckets",
|
"data_buckets",
|
||||||
|
"discovered_items",
|
||||||
|
"eventlog",
|
||||||
"faction_values",
|
"faction_values",
|
||||||
"friends",
|
"friends",
|
||||||
"guild_bank",
|
"guild_bank",
|
||||||
@ -141,9 +146,12 @@ namespace DatabaseSchema {
|
|||||||
"inventory_snapshots",
|
"inventory_snapshots",
|
||||||
"keyring",
|
"keyring",
|
||||||
"mail",
|
"mail",
|
||||||
|
"petitions",
|
||||||
"player_titlesets",
|
"player_titlesets",
|
||||||
"quest_globals",
|
"quest_globals",
|
||||||
|
"saylink",
|
||||||
"sharedbank",
|
"sharedbank",
|
||||||
|
"reports",
|
||||||
"timers",
|
"timers",
|
||||||
"titles",
|
"titles",
|
||||||
"trader",
|
"trader",
|
||||||
@ -255,13 +263,9 @@ namespace DatabaseSchema {
|
|||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"banned_ips",
|
"banned_ips",
|
||||||
"bugs",
|
|
||||||
"bug_reports",
|
|
||||||
"command_settings",
|
"command_settings",
|
||||||
"db_str",
|
"db_str",
|
||||||
"discovered_items",
|
|
||||||
"eqtime",
|
"eqtime",
|
||||||
"eventlog",
|
|
||||||
"gm_ips",
|
"gm_ips",
|
||||||
"hackers",
|
"hackers",
|
||||||
"ip_exemptions",
|
"ip_exemptions",
|
||||||
@ -271,12 +275,9 @@ namespace DatabaseSchema {
|
|||||||
"logsys_categories",
|
"logsys_categories",
|
||||||
"name_filter",
|
"name_filter",
|
||||||
"perl_event_export_settings",
|
"perl_event_export_settings",
|
||||||
"petitions",
|
|
||||||
"profanity_list",
|
"profanity_list",
|
||||||
"reports",
|
|
||||||
"rule_sets",
|
"rule_sets",
|
||||||
"rule_values",
|
"rule_values",
|
||||||
"saylink",
|
|
||||||
"variables",
|
"variables",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
47
utils/sql/peq-dump/peq-dump.sh
Executable file
47
utils/sql/peq-dump/peq-dump.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
world_path=""
|
||||||
|
|
||||||
|
if [ -d "bin" ]
|
||||||
|
then
|
||||||
|
world_path="bin/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
world_bin="${world_path}world"
|
||||||
|
|
||||||
|
echo "World path is [$world_path] bin is [$world_bin]"
|
||||||
|
|
||||||
|
# Run from the context of server directory
|
||||||
|
#
|
||||||
|
# --content-tables
|
||||||
|
# --login-tables
|
||||||
|
# --player-tables
|
||||||
|
# --system-tables
|
||||||
|
# --query-serv-tables
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# dump
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
dump_path=/tmp/peq-dump/
|
||||||
|
|
||||||
|
mkdir -p ${dump_path}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# generate "drop_" table files
|
||||||
|
#############################################
|
||||||
|
bash -c "${world_bin} database:dump --content-tables --drop-table-syntax-only --dump-output-to-console > ${dump_path}drop_tables_content.sql"
|
||||||
|
bash -c "${world_bin} database:dump --login-tables --drop-table-syntax-only --dump-output-to-console > ${dump_path}drop_tables_login.sql"
|
||||||
|
bash -c "${world_bin} database:dump --player-tables --drop-table-syntax-only --dump-output-to-console > ${dump_path}drop_tables_player.sql"
|
||||||
|
bash -c "${world_bin} database:dump --system-tables --drop-table-syntax-only --dump-output-to-console > ${dump_path}drop_tables_system.sql"
|
||||||
|
bash -c "${world_bin} database:dump --query-serv-tables --drop-table-syntax-only --dump-output-to-console > ${dump_path}drop_tables_queryserv.sql"
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
# generate "create_" table files
|
||||||
|
#############################################
|
||||||
|
bash -c "${world_bin} database:dump --content-tables --dump-output-to-console > ${dump_path}create_tables_content.sql"
|
||||||
|
bash -c "${world_bin} database:dump --login-tables --table-structure-only --dump-output-to-console > ${dump_path}create_tables_login.sql"
|
||||||
|
bash -c "${world_bin} database:dump --player-tables --table-structure-only --dump-output-to-console > ${dump_path}create_tables_player.sql"
|
||||||
|
bash -c "${world_bin} database:dump --system-tables --dump-output-to-console > ${dump_path}create_tables_system.sql"
|
||||||
|
bash -c "${world_bin} database:dump --query-serv-tables --table-structure-only --dump-output-to-console > ${dump_path}create_tables_queryserv.sql"
|
||||||
|
|
||||||
@ -227,9 +227,10 @@ namespace WorldserverCommandHandler {
|
|||||||
"--system-tables",
|
"--system-tables",
|
||||||
"--query-serv-tables",
|
"--query-serv-tables",
|
||||||
"--table-structure-only",
|
"--table-structure-only",
|
||||||
"--no-table-lock",
|
"--table-lock",
|
||||||
"--dump-path=",
|
"--dump-path=",
|
||||||
"--dump-output-to-console",
|
"--dump-output-to-console",
|
||||||
|
"--drop-table-syntax-only",
|
||||||
"--compress"
|
"--compress"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,9 +257,10 @@ namespace WorldserverCommandHandler {
|
|||||||
database_dump_service->SetDumpWithNoData(cmd[{"-c", "--table-structure-only"}]);
|
database_dump_service->SetDumpWithNoData(cmd[{"-c", "--table-structure-only"}]);
|
||||||
database_dump_service->SetDumpQueryServerTables(cmd[{"--query-serv-tables"}]);
|
database_dump_service->SetDumpQueryServerTables(cmd[{"--query-serv-tables"}]);
|
||||||
database_dump_service->SetDumpAllTables(dump_all);
|
database_dump_service->SetDumpAllTables(dump_all);
|
||||||
database_dump_service->SetDumpNoTableLock(cmd[{"--no-table-lock"}]);
|
database_dump_service->SetDumpTableLock(cmd[{"--table-lock"}]);
|
||||||
database_dump_service->SetDumpWithCompression(cmd[{"--compress"}]);
|
database_dump_service->SetDumpWithCompression(cmd[{"--compress"}]);
|
||||||
database_dump_service->SetDumpOutputToConsole(cmd[{"--dump-output-to-console"}]);
|
database_dump_service->SetDumpOutputToConsole(cmd[{"--dump-output-to-console"}]);
|
||||||
|
database_dump_service->SetDumpDropTableSyntaxOnly(cmd[{"--drop-table-syntax-only"}]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump
|
* Dump
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user