From 27fd810cfd61d00b583e78414a112b563f997994 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 24 Mar 2015 02:28:26 +1100 Subject: [PATCH] Added a simple database update script, and comment headers I don't know why it took me this long to add those headers in the first place. (cherry picked from commit 3c28b6c3bf75c4bdb42e5ea9d9864efaa855620c) --- rsc/scripts/door_utility.lua | 24 ++++++++++++++++ rsc/scripts/map_maker.lua | 24 ++++++++++++++++ rsc/scripts/map_saver.lua | 24 ++++++++++++++++ rsc/scripts/setup_server.lua | 24 ++++++++++++++++ rsc/scripts/setup_server.sql | 22 +++++++++++++++ rsc/scripts/updates.sql | 54 ++++++++++++++++++++++++++++++++++++ 6 files changed, 172 insertions(+) create mode 100644 rsc/scripts/updates.sql diff --git a/rsc/scripts/door_utility.lua b/rsc/scripts/door_utility.lua index d1fc648..8c9447e 100644 --- a/rsc/scripts/door_utility.lua +++ b/rsc/scripts/door_utility.lua @@ -1,3 +1,27 @@ +--[[ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ +--]] + local doorUtility = {} roomAPI = require("room") diff --git a/rsc/scripts/map_maker.lua b/rsc/scripts/map_maker.lua index d2a7f4e..69ed519 100644 --- a/rsc/scripts/map_maker.lua +++ b/rsc/scripts/map_maker.lua @@ -1,3 +1,27 @@ +--[[ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ +--]] + local regionAPI = require("region") local mapMaker = {} diff --git a/rsc/scripts/map_saver.lua b/rsc/scripts/map_saver.lua index 2ec8832..f2f4ea0 100644 --- a/rsc/scripts/map_saver.lua +++ b/rsc/scripts/map_saver.lua @@ -1,3 +1,27 @@ +--[[ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ +--]] + local region = require("region") local mapSaver = {} diff --git a/rsc/scripts/setup_server.lua b/rsc/scripts/setup_server.lua index 5c55900..2f22c67 100644 --- a/rsc/scripts/setup_server.lua +++ b/rsc/scripts/setup_server.lua @@ -1,3 +1,27 @@ +--[[ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ +--]] + print("Lua script check") --requirements diff --git a/rsc/scripts/setup_server.sql b/rsc/scripts/setup_server.sql index d672072..809f736 100644 --- a/rsc/scripts/setup_server.sql +++ b/rsc/scripts/setup_server.sql @@ -1,3 +1,25 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ + --TODO: (3) An archive table of all dead characters CREATE TABLE IF NOT EXISTS UserAccounts ( diff --git a/rsc/scripts/updates.sql b/rsc/scripts/updates.sql new file mode 100644 index 0000000..2f0f817 --- /dev/null +++ b/rsc/scripts/updates.sql @@ -0,0 +1,54 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. +*/ + +--TODO: might need a version number for database structures + +--An example of a database update script. +--This is only rough right now, until I get some more eyes onto it + +--moving old to new +CREATE TABLE tempCharacters ( + uid INTEGER PRIMARY KEY AUTOINCREMENT, + + --metadata + owner INTEGER REFERENCES Accounts(uid), + handle varchar(100) UNIQUE, + avatar varchar(100), + birth timestamp NOT NULL DEFAULT (datetime()), + + --physically exists in the world + roomIndex INTEGER DEFAULT 0, + originX INTEGER DEFAULT 0, + originY INTEGER DEFAULT 0, + boundsX INTEGER DEFAULT 0, + boundsY INTEGER DEFAULT 0, + boundsW INTEGER DEFAULT 0, + boundsH INTEGER DEFAULT 0 +); + +INSERT INTO tempCharacters (uid, owner, handle, avatar, birth, roomIndex, originX, originY, boundsX, boundsY, boundsW, boundsH) + SELECT uid, owner, handle, avatar, birth, roomIndex, originX, originY, boundsX, boundsY, boundsW, boundsH + FROM LiveCharacters; + +DROP TABLE LiveCharacters; + +ALTER TABLE tempCharacters RENAME TO LiveCharacters;