From 1afbfb7e5fb5c133924ed8d376c6064575fc1c36 Mon Sep 17 00:00:00 2001
From: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
Date: Mon, 12 Mar 2012 22:18:22 +0100
Subject: Fixed problems with map-bound world state variables

Due to a wrong primary key, which covered only the state name, it was
impossible to use the same state name on different maps. This has now
been fixed.

Another problem was that the map variables were being included in the
global variables, because the related database query did not filter on
the map_id column properly. While fixing that, the map_id column now
allows explicitly marking a state variable as global (with the value 0)
or system variables (with the value -1).

System variables are currently not accessible from scripts, but that
could be changed later.

Reviewed-by: Yohann Ferreira
Reviewed-by: Erik Schilling
---
 src/sql/postgresql/createTables.sql | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'src/sql/postgresql/createTables.sql')

diff --git a/src/sql/postgresql/createTables.sql b/src/sql/postgresql/createTables.sql
index 278790a..53526dc 100644
--- a/src/sql/postgresql/createTables.sql
+++ b/src/sql/postgresql/createTables.sql
@@ -110,10 +110,11 @@ CREATE TABLE mana_quests
 
 CREATE TABLE mana_world_states
 (
-   state_name   TEXT        PRIMARY KEY,
-   map_id       INTEGER     NULL,
-   value        TEXT        NULL,
-   moddate      INTEGER     NOT NULL
+   state_name   TEXT        NOT NULL,
+   map_id       INTEGER     NOT NULL,
+   value        TEXT        NOT NULL,
+   moddate      INTEGER     NOT NULL,
+   PRIMARY KEY (`state_name`, `map_id`)
 );
 
 INSERT INTO "mana_world_states" VALUES('accountserver_startup',NULL,NULL,1221633910);
-- 
cgit 

