Files
discord-markov/db.sql

30 lines
987 B
MySQL
Raw Normal View History

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);