From 634554a0df8dfd35630f17b5fee44c54b7af73a5 Mon Sep 17 00:00:00 2001
From: fusion32 <marcopuzziello@gmail.com>
Date: Fri, 1 Aug 2025 19:23:13 -0300
Subject: fix problem with concurrent writes + implement website queries

  There was a problem with concurrent writes not being visible
until after restart, due to how cached prepared statements work
with SQLite (see comment in `database.cc`).
---
 sql/schema.sql | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

(limited to 'sql/schema.sql')

diff --git a/sql/schema.sql b/sql/schema.sql
index c8a78ec..90f59a8 100644
--- a/sql/schema.sql
+++ b/sql/schema.sql
@@ -6,12 +6,16 @@ CREATE TABLE IF NOT EXISTS Worlds (
 	Type INTEGER NOT NULL,
 	RebootTime INTEGER NOT NULL,
 	IPAddress INTEGER NOT NULL,
+	-- TODO(fusion): Have some hostname resolution cache and send the resolved
+	-- addresses instead of hardcoding them into the database.
+	--Host TEXT NOT NULL,
 	Port INTEGER NOT NULL,
 	MaxPlayers INTEGER NOT NULL,
 	PremiumPlayerBuffer INTEGER NOT NULL,
 	MaxNewbies INTEGER NOT NULL,
 	PremiumNewbieBuffer INTEGER NOT NULL,
 	OnlineRecord INTEGER NOT NULL DEFAULT 0,
+	OnlineRecordTimestamp INTEGER NOT NULL DEFAULT 0,
 	PRIMARY KEY (WorldID),
 	UNIQUE (Name)
 );
@@ -275,6 +279,16 @@ INSERT INTO Accounts (AccountID, Email, Auth)
 INSERT INTO Characters (WorldID, CharacterID, AccountID, Name, Sex)
 	VALUES (1, 1, 111111, 'Gamemaster', 1), (1, 2, 111111, 'Player', 1);
 
+/*
+-- TODO(fusion): Have group rights instead of adding individual rights to characters?
+ALTER TABLE Characters ADD GroupID INTEGER NOT NULL;
+CREATE TABLE IF NOT EXISTS CharacterRights (
+	GroupID INTEGER NOT NULL,
+	Right TEXT NOT NULL COLLATE NOCASE,
+	PRIMARY KEY(GroupID, Right)
+);
+*/
+
 INSERT INTO CharacterRights (CharacterID, Right)
 	VALUES
 		(1, 'NOTATION'),
-- 
cgit v1.2.3

