messenger_postgresql.sql 5.55 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5 6 7
-- $RCSfile$
-- $Revision$
-- $Date$

-- Note: This schema has only been tested on PostgreSQL 7.3.2.

CREATE TABLE jiveUser (
Matt Tucker's avatar
Matt Tucker committed
8
  username              VARCHAR(32)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
9 10 11 12 13
  password              VARCHAR(32)     NOT NULL,
  name                  VARCHAR(100),
  email                 VARCHAR(100),
  creationDate          CHAR(15)        NOT NULL,
  modificationDate      CHAR(15)        NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
14
  CONSTRAINT jiveUser_pk PRIMARY KEY (username)
Matt Tucker's avatar
Matt Tucker committed
15 16 17 18 19
);
CREATE INDEX jiveUser_cDate_idx ON jiveUser (creationDate);


CREATE TABLE jiveUserProp (
Matt Tucker's avatar
Matt Tucker committed
20
  username              VARCHAR(32)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
21 22
  name                  VARCHAR(100)    NOT NULL,
  propValue             TEXT            NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
23
  CONSTRAINT jiveUserProp_pk PRIMARY KEY (username, name)
Matt Tucker's avatar
Matt Tucker committed
24 25 26 27
);


CREATE TABLE jivePrivate (
Matt Tucker's avatar
Matt Tucker committed
28
  username              VARCHAR(32)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
29 30 31
  name                  VARCHAR(100)    NOT NULL,
  namespace             VARCHAR(200)    NOT NULL,
  value                 TEXT            NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
32
  CONSTRAINT jivePrivate_pk PRIMARY KEY (username, name, namespace)
Matt Tucker's avatar
Matt Tucker committed
33 34 35 36
);


CREATE TABLE jiveOffline (
Matt Tucker's avatar
Matt Tucker committed
37
  username              VARCHAR(32)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
38 39 40
  messageID             INTEGER         NOT NULL,
  creationDate          CHAR(15)        NOT NULL,
  messageSize           INTEGER         NOT NULL,
41
  message               TEXT            NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
42
  CONSTRAINT jiveOffline_pk PRIMARY KEY (username, messageID)
Matt Tucker's avatar
Matt Tucker committed
43 44 45 46 47
);


CREATE TABLE jiveRoster (
  rosterID              INTEGER         NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
48 49
  username              VARCHAR(32)     NOT NULL,
  jid                   VARCHAR(1024)   NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
50 51 52 53 54 55
  sub                   INTEGER         NOT NULL,
  ask                   INTEGER         NOT NULL,
  recv                  INTEGER         NOT NULL,
  nick                  VARCHAR(255),
  CONSTRAINT jiveRoster_pk PRIMARY KEY (rosterID)
);
Matt Tucker's avatar
Matt Tucker committed
56
CREATE INDEX jiveRoster_username_idx ON jiveRoster (username);
Matt Tucker's avatar
Matt Tucker committed
57 58 59 60 61 62 63 64 65 66 67 68 69


CREATE TABLE jiveRosterGroups (
  rosterID              INTEGER         NOT NULL,
  rank                  INTEGER         NOT NULL,
  groupName             VARCHAR(255)    NOT NULL,
  CONSTRAINT jiveRosterGroups_pk PRIMARY KEY (rosterID, rank)
);
CREATE INDEX jiveRosterGroups_rosterID_idx ON jiveRosterGroups (rosterID);
ALTER TABLE jiveRosterGroups ADD CONSTRAINT jiveRosterGroups_rosterID_fk FOREIGN KEY (rosterID) REFERENCES jiveRoster INITIALLY DEFERRED DEFERRABLE;


CREATE TABLE jiveVCard (
Matt Tucker's avatar
Matt Tucker committed
70
  username              VARCHAR(32)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
71 72
  name                  VARCHAR(100)    NOT NULL,
  propValue             TEXT            NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
73
  CONSTRAINT jiveVCard_pk PRIMARY KEY (username, name)
Matt Tucker's avatar
Matt Tucker committed
74 75 76 77
);


CREATE TABLE jiveGroup (
78
  groupName             VARCHAR(50)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
79
  description           VARCHAR(255),
80
  CONSTRAINT jiveGroup_pk PRIMARY KEY (groupName)
Matt Tucker's avatar
Matt Tucker committed
81 82 83 84
);


CREATE TABLE jiveGroupProp (
Matt Tucker's avatar
Matt Tucker committed
85
  groupName             VARCHAR(50)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
86 87
  name                  VARCHAR(100)    NOT NULL,
  propValue             TEXT            NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
88
  CONSTRAINT jiveGroupProp_pk PRIMARY KEY (groupName, name)
Matt Tucker's avatar
Matt Tucker committed
89 90 91 92
);


CREATE TABLE jiveGroupUser (
Matt Tucker's avatar
Matt Tucker committed
93
  groupName             VARCHAR(50)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
94
  username              VARCHAR(32)     NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
95
  administrator         INTEGER         NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
96
  CONSTRAINT jiveGroupUser_pk PRIMARY KEY (groupName, username, administrator)
Matt Tucker's avatar
Matt Tucker committed
97
);
Matt Tucker's avatar
Matt Tucker committed
98
 
Matt Tucker's avatar
Matt Tucker committed
99 100 101 102 103 104 105

CREATE TABLE jiveID (
  idType                INTEGER         NOT NULL,
  id                    INTEGER         NOT NULL,
  CONSTRAINT jiveID_pk PRIMARY KEY (idType)
);

106 107 108 109 110 111
CREATE TABLE jiveProperty (
  name        VARCHAR(100) NOT NULL,
  propValue   VARCHAR(4000) NOT NULL,
  CONSTRAINT jiveProperty_pk PRIMARY KEY (name)
);

Gaston Dombiak's avatar
Gaston Dombiak committed
112 113 114 115
-- MUC Tables

CREATE TABLE mucRoom (
  roomID              INTEGER       NOT NULL,
116 117
  creationDate        CHAR(15)      NOT NULL,
  modificationDate    CHAR(15)      NOT NULL,
118
  name                VARCHAR(50)   NOT NULL,
119
  naturalName         VARCHAR(255)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
  description         VARCHAR(255),
  canChangeSubject    INTEGER       NOT NULL,
  maxUsers            INTEGER       NOT NULL,
  publicRoom          INTEGER       NOT NULL,
  moderated           INTEGER       NOT NULL,
  invitationRequired  INTEGER       NOT NULL,
  canInvite           INTEGER       NOT NULL,
  password            VARCHAR(50)   NULL,
  canDiscoverJID      INTEGER       NOT NULL,
  logEnabled          INTEGER       NOT NULL,
  subject             VARCHAR(100)  NULL,
  rolesToBroadcast    INTEGER       NOT NULL,
  CONSTRAINT mucRoom__pk PRIMARY KEY (name)
);

CREATE INDEX mucRoom_roomID_idx ON mucRoom(roomID);

CREATE TABLE mucAffiliation (
  roomID              INTEGER        NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
139
  jid                 VARCHAR(1024)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
140 141 142 143 144 145
  affiliation         INTEGER        NOT NULL,
  CONSTRAINT mucAffiliation__pk PRIMARY KEY (roomID,jid)
);

CREATE TABLE mucMember (
  roomID              INTEGER        NOT NULL,
146
  jid                 VARCHAR(1024)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
147 148 149 150 151 152
  nickname            VARCHAR(255)   NULL,
  CONSTRAINT mucMember__pk PRIMARY KEY (roomID,jid)
);

CREATE TABLE mucConversationLog (
  roomID              INTEGER        NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
153
  sender              VARCHAR(1024)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
154 155 156 157 158
  nickname            VARCHAR(255)   NULL,
  time                CHAR(15)       NOT NULL,
  subject             VARCHAR(255)   NULL,
  body                TEXT           NULL
);
159
CREATE INDEX mucLog_time_idx ON mucConversationLog (time);
Matt Tucker's avatar
Matt Tucker committed
160 161 162 163 164 165 166

-- Finally, insert default table values.

INSERT INTO jiveID (idType, id) VALUES (18, 1);
INSERT INTO jiveID (idType, id) VALUES (19, 1);
INSERT INTO jiveID (idType, id) VALUES (23, 1);

Matt Tucker's avatar
Matt Tucker committed
167 168 169
-- Entry for admin user
INSERT INTO jiveUser (username, password, name, email, creationDate, modificationDate)
    VALUES ('admin', 'admin', 'Administrator', 'admin@example.com', '0', '0');