Enforce U in UUID.
authorCMDR furrycat <elite@furrycat.net>
Wed, 5 Oct 2016 11:09:20 +0000 (12:09 +0100)
committerCMDR furrycat <elite@furrycat.net>
Wed, 5 Oct 2016 11:09:20 +0000 (12:09 +0100)
db.py

diff --git a/db.py b/db.py
index 7e2ade9..01575e0 100644 (file)
--- a/db.py
+++ b/db.py
@@ -31,7 +31,10 @@ class DBConnection(object):
   def create_tables(self):
     self.open_db()
     cursor = self.query('create table if not exists state (id char(36) not null, bot_id varchar(32) not null, avatar varchar(128), idle boolean not null default false, last_spoke datetime)')
+    cursor = self.query('create unique index if not exists state_id on state (id)')
+    cursor = self.query('create unique index if not exists state_bot_id on state (bot_id)')
     cursor = self.query('create table if not exists announcements (id char(36) not null, bot_id varchar(32) not null, server_id varchar(32) not null, member_id varchar(32) not null, channel_id varchar(32) not null, voice_id varchar(32), sound varchar(128), mention varchar(32), start_date datetime, end_date datetime, interval int, probability float not null default 1.0, last_spoke datetime, message text, digest char(56))')
+    cursor = self.query('create unique index if not exists announcements_id on announcements (id)')
     self.dbh.commit()
     self.close_db()