~ci-train-bot/history-service/history-service-ubuntu-zesty-2629

« back to all changes in this revision

Viewing changes to plugins/sqlite/schema/v13.sql

  • Committer: Bileto Bot
  • Author(s): Gustavo Pichorim Boiko
  • Date: 2016-11-30 15:13:58 UTC
  • mfrom: (230.2.23 staging)
  • Revision ID: ci-train-bot@canonical.com-20161130151358-jy3mqj0ir0b6ncxe
Improve group chat support.

Approved by: Roberto Mier Escandón , Tiago Salem Herrmann

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
ALTER TABLE threads ADD COLUMN chatType tinyint;
 
2
ALTER TABLE thread_participants ADD COLUMN alias varchar(255);
 
3
ALTER TABLE thread_participants ADD COLUMN state tinyint;
 
4
CREATE TABLE chat_room_info (
 
5
    accountId varchar(255),
 
6
    type tinyint,
 
7
    threadId varchar(255),
 
8
    roomName varchar(255),
 
9
    server varchar(255),
 
10
    creator varchar(255),
 
11
    creationTimestamp datetime,
 
12
    anonymous boolean,
 
13
    inviteOnly boolean,
 
14
    participantLimit integer,
 
15
    moderated boolean,
 
16
    title varchar(1024),
 
17
    description varchar(1024),
 
18
    persistent boolean,
 
19
    private boolean,
 
20
    passwordProtected boolean,
 
21
    password varchar(512),
 
22
    passwordHint varchar(512),
 
23
    canUpdateConfiguration boolean,
 
24
    subject varchar(1024),
 
25
    actor varchar(512),
 
26
    timestamp datetime
 
27
);
 
28
UPDATE threads SET chatType = 0;
 
29
UPDATE threads SET chatType=1 WHERE (SELECT COUNT(participantId) from thread_participants WHERE thread_participants.threadId=threads.threadId and thread_participants.accountId=threads.accountId AND thread_participants.type=threads.type)=1;
 
30
UPDATE thread_participants SET state = 0;
 
31
 
 
32
DROP TRIGGER threads_delete_trigger;
 
33
CREATE TRIGGER threads_delete_trigger AFTER DELETE ON threads
 
34
FOR EACH ROW
 
35
BEGIN
 
36
    DELETE FROM thread_participants WHERE
 
37
        accountId=old.accountId AND
 
38
        threadId=old.threadId AND
 
39
        type=old.type;
 
40
    DELETE FROM chat_room_info WHERE
 
41
        accountId=old.accountId AND
 
42
        threadId=old.threadId AND
 
43
        type=old.type;
 
44
END;