Files
DarkflameServer/migrations/dlu/sqlite/84_chat_flags.sql
Aaron Kimbrell af54ca282f feat(db): chat log guild, team and filter result; chat flags
chat_log gets guild_id, team_id and filtered (migrations mysql 100, sqlite 83),
and the chat log queries take a time range, a guild, a team, a conversation
between two characters and paging back by id. Whispers are their own visibility
switch (includeWhispers), apart from team and guild chat (includePrivate).
Whisper partners and teams that talked are listed with counts.

chat_flags, chat_flag_messages and chat_flag_events (mysql 101, sqlite 84) hold
flagged chat with a copy of the messages around it, its status, note, linked
player report and history. Open flags are in the dashboard snapshot.

Tests on SQLite alone (dDatabaseSqliteTests) and in the MySQL parity tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 18:23:22 -05:00

44 lines
1.7 KiB
SQL

/* Chat flags, the chat_log rows they cover and their history. See the MySQL migration. */
CREATE TABLE IF NOT EXISTS chat_flags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at BIGINT NOT NULL,
created_by_id INTEGER NOT NULL DEFAULT 0,
created_by TEXT NOT NULL DEFAULT '',
status TEXT NOT NULL DEFAULT 'open',
channel TEXT NOT NULL,
character_id BIGINT NOT NULL DEFAULT 0,
character_name TEXT NOT NULL DEFAULT '',
account_id INTEGER NOT NULL DEFAULT 0,
first_message_id BIGINT NOT NULL DEFAULT 0,
last_message_id BIGINT NOT NULL DEFAULT 0,
first_time BIGINT NOT NULL DEFAULT 0,
last_time BIGINT NOT NULL DEFAULT 0,
excerpt TEXT NOT NULL DEFAULT '',
note TEXT NOT NULL DEFAULT '',
messages TEXT NOT NULL DEFAULT '[]',
player_report_id BIGINT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL DEFAULT 0,
updated_by TEXT NOT NULL DEFAULT ''
);
CREATE INDEX IF NOT EXISTS chat_flags_status ON chat_flags (status);
CREATE INDEX IF NOT EXISTS chat_flags_character ON chat_flags (character_id);
CREATE INDEX IF NOT EXISTS chat_flags_account ON chat_flags (account_id);
CREATE TABLE IF NOT EXISTS chat_flag_messages (
flag_id BIGINT NOT NULL,
message_id BIGINT NOT NULL,
PRIMARY KEY (flag_id, message_id)
);
CREATE INDEX IF NOT EXISTS chat_flag_messages_message ON chat_flag_messages (message_id);
CREATE TABLE IF NOT EXISTS chat_flag_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flag_id BIGINT NOT NULL,
time BIGINT NOT NULL,
account_id INTEGER NOT NULL DEFAULT 0,
actor TEXT NOT NULL DEFAULT '',
action TEXT NOT NULL,
detail TEXT NOT NULL DEFAULT ''
);
CREATE INDEX IF NOT EXISTS chat_flag_events_flag ON chat_flag_events (flag_id);