countdown-bot

A Discord bot that runs countdown games and generates analytics
git clone https://git.ashermorgan.net/countdown-bot/
Log | Files | Refs | README

ddl.sql (1612B)


      1 -- countdown-bot table definitions
      2 
      3 DROP TABLE IF EXISTS reactions;
      4 DROP TABLE IF EXISTS prefixes;
      5 DROP TABLE IF EXISTS messages;
      6 DROP TABLE IF EXISTS countdowns;
      7 
      8 -- Records countdown channels
      9 CREATE TABLE countdowns (
     10     countdownID BIGINT PRIMARY KEY,        -- The Discord channel ID
     11     serverID BIGINT NOT NULL,              -- The channel's Discord server ID
     12     timezone INTERVAL NOT NULL DEFAULT '0' -- The preferred UTC offset
     13 );
     14 
     15 -- Records contributions to countdowns
     16 CREATE TABLE messages (
     17     messageID BIGINT PRIMARY KEY,      -- The Discord message ID
     18     countdownID BIGINT NOT NULL,       -- The countdown ID
     19     userID BIGINT NOT NULL,            -- The author's Discord user ID
     20     value INT NOT NULL,                -- The message's numeric value
     21     timestamp TIMESTAMPTZ NOT NULL,    -- The message timestamp
     22     FOREIGN KEY (countdownID)
     23         REFERENCES countdowns(countdownID)
     24         ON DELETE CASCADE
     25 );
     26 
     27 -- Records bot command prefixes
     28 CREATE table prefixes (
     29     prefixID SERIAL PRIMARY KEY, -- The prefix ID
     30     countdownID BIGINT NOT NULL, -- The countdown ID
     31     value VARCHAR(8) NOT NULL,   -- The prefix
     32     FOREIGN KEY (countdownID)
     33         REFERENCES countdowns(countdownID)
     34         ON DELETE CASCADE
     35 );
     36 
     37 -- Records custom countdown reactions
     38 CREATE table reactions (
     39     prefixID SERIAL PRIMARY KEY, -- The reaction ID
     40     countdownID BIGINT NOT NULL, -- The countdown ID
     41     number INT NOT NULL,         -- The prefix
     42     value VARCHAR(8) NOT NULL,   -- The reaction
     43     FOREIGN KEY (countdownID)
     44         REFERENCES countdowns(countdownID)
     45         ON DELETE CASCADE
     46 );