From 352fde7eedf72e652dc300bd99cd1326c98e8430 Mon Sep 17 00:00:00 2001 From: Alffd Date: Mon, 10 Jul 2017 20:59:03 -0400 Subject: [PATCH] SQL version control --- SQL/updates/Readme.md | 7 +++++++ code/__DEFINES/misc.dm | 3 +++ code/controllers/configuration.dm | 11 +++++++++++ config/example/dbconfig.txt | 8 +++++++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 SQL/updates/Readme.md diff --git a/SQL/updates/Readme.md b/SQL/updates/Readme.md new file mode 100644 index 00000000000..29d7ad0287a --- /dev/null +++ b/SQL/updates/Readme.md @@ -0,0 +1,7 @@ +### UPDATING SQL +The contents of this directory contain update sql scripts for the paracode SQL database. + +Files following the naming convention -.sql +Files are designed to be run sequentialy, moving from version 2, to version 4 would require running the following SQL scripts. +2-3.sql +3-4.sql \ No newline at end of file diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 61e5e5069b4..1142f614775 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -347,3 +347,6 @@ #define BLOOD_STATE_HUMAN "blood" #define BLOOD_STATE_XENO "xeno" #define BLOOD_STATE_NOT_BLOODY "no blood whatsoever" + +// The SQL version required by this version of the code +#define SQL_VERSION 0 diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 2ab267ce5a8..6fb873c9391 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -667,6 +667,7 @@ /datum/configuration/proc/loadsql(filename) // -- TLE var/list/Lines = file2list(filename) + var/db_version = 0 for(var/t in Lines) if(!t) continue @@ -704,8 +705,18 @@ sqlfdbkpass = value if("feedback_tableprefix") sqlfdbktableprefix = value + if("db_version") + db_version = text2num(value) else diary << "Unknown setting in configuration: '[name]'" + if(config.sql_enabled && db_version != SQL_VERSION) + config.sql_enabled = 0 + diary << "WARNING: DB_CONFIG DEFINITION MISMATCH!" + spawn(60) + if(ticker.current_state == GAME_STATE_PREGAME) + going = 0 + spawn(600) + to_chat(world, "DB_CONFIG MISMATCH, ROUND START DELAYED.
Please check database version for recent upstream changes!
") /datum/configuration/proc/loadoverflowwhitelist(filename) var/list/Lines = file2list(filename) diff --git a/config/example/dbconfig.txt b/config/example/dbconfig.txt index 4dd55974678..e713bda4c7d 100644 --- a/config/example/dbconfig.txt +++ b/config/example/dbconfig.txt @@ -5,6 +5,12 @@ ## Should SQL be enabled? Uncomment to enable. #SQL_ENABLED +## Database version. This value is used if SQL_ENABLED is uncommented +## This value must be set to the version of the paradise schema in use. +## If this value does not match, the SQL database will not be loaded and an error will be generated. +## Roundstart will be delayed. +DB_VERSION 0 + ## Server the MySQL database can be found at. # Examples: localhost, 200.135.5.43, www.mysqldb.com, etc. ADDRESS localhost @@ -30,4 +36,4 @@ FEEDBACK_TABLEPREFIX FEEDBACK_LOGIN username ## Password used to access the database. -FEEDBACK_PASSWORD password \ No newline at end of file +FEEDBACK_PASSWORD password