DROP TABLE IF EXISTS guild_points_history;
CREATE TABLE guild_points_history (
	id           INTEGER PRIMARY KEY,
	guild_id     INTEGER NOT NULL DEFAULT 0,
	char_id      INTEGER NOT NULL DEFAULT 0,
	points_date  INTEGER NOT NULL DEFAULT 0,
	modified_by  TEXT NOT NULL DEFAULT '',
	comment      TEXT,
	points       REAL NOT NULL DEFAULT 0,
	FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE ON UPDATE CASCADE,
	FOREIGN KEY (char_id) REFERENCES characters(id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX idx_guild_points_history_guild_char ON guild_points_history(guild_id, char_id);
CREATE INDEX idx_guild_points_history_char_id ON guild_points_history(char_id);
