Files
discord-markov/db.sql
Alek Ratzloff cd57db2440 Add markov_all_index to the database
This speeds up markov all quite a bit.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2025-06-29 20:33:45 -07:00

33 lines
1.0 KiB
SQL

CREATE TABLE IF NOT EXISTS channel (
id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
guild_id integer NOT NULL,
channel_id integer NOT NULL,
/* last_message needs to be set to 1420070400.0, which is Jan 1 2015 */
last_message decimal NOT NULL DEFAULT 1420070400.0
);
CREATE UNIQUE INDEX IF NOT EXISTS unique_channel ON channel(channel_id);
CREATE TABLE IF NOT EXISTS user (
id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
guild_id integer NOT NULL,
member_id integer NOT NULL,
reply_chance real NOT NULL,
listen integer NOT NULL DEFAULT 1
);
CREATE UNIQUE INDEX IF NOT EXISTS guild_member ON user(guild_id, member_id);
CREATE TABLE IF NOT EXISTS chain (
id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
user integer NOT NULL,
value text NOT NULL,
weight integer NOT NULL DEFAULT 1,
next text NOT NULL,
FOREIGN KEY(user) REFERENCES user(id)
);
CREATE UNIQUE INDEX IF NOT EXISTS chain_value_next ON chain(user, value, next);
CREATE INDEX IF NOT EXISTS markov_all_index ON chain(value);