messenger_postgresql.sql 6.78 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,
71 72
  value                 TEXT            NOT NULL,
  CONSTRAINT jiveVCard_pk PRIMARY KEY (username)
Matt Tucker's avatar
Matt Tucker committed
73 74 75 76
);


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


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


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

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

Matt Tucker's avatar
Matt Tucker committed
105

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

Matt Tucker's avatar
Matt Tucker committed
112 113 114 115 116 117

CREATE TABLE jiveVersion (
  majorVersion  INTEGER  NOT NULL,
  minorVersion  INTEGER  NOT NULL
);

118 119 120 121 122 123 124 125 126 127 128 129 130 131
CREATE TABLE jiveExtComponentConf (
  subdomain             VARCHAR(255)    NOT NULL,
  secret                VARCHAR(255),
  permission            VARCHAR(10)     NOT NULL,
  CONSTRAINT jiveExtComponentConf_pk PRIMARY KEY (subdomain)
);

CREATE TABLE jiveRemoteServerConf (
  domain                VARCHAR(255)    NOT NULL,
  remotePort            INTEGER,
  permission            VARCHAR(10)     NOT NULL,
  CONSTRAINT jiveRemoteServerConf_pk PRIMARY KEY (domain)
);

Gaston Dombiak's avatar
Gaston Dombiak committed
132 133 134 135
-- MUC Tables

CREATE TABLE mucRoom (
  roomID              INTEGER       NOT NULL,
136 137
  creationDate        CHAR(15)      NOT NULL,
  modificationDate    CHAR(15)      NOT NULL,
138
  name                VARCHAR(50)   NOT NULL,
139
  naturalName         VARCHAR(255)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
140
  description         VARCHAR(255),
141
  lockedDate          CHAR(15)      NOT NULL,
142
  emptyDate           CHAR(15)      NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
143 144 145 146
  canChangeSubject    INTEGER       NOT NULL,
  maxUsers            INTEGER       NOT NULL,
  publicRoom          INTEGER       NOT NULL,
  moderated           INTEGER       NOT NULL,
147
  membersOnly         INTEGER       NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
148 149 150 151 152 153
  canInvite           INTEGER       NOT NULL,
  password            VARCHAR(50)   NULL,
  canDiscoverJID      INTEGER       NOT NULL,
  logEnabled          INTEGER       NOT NULL,
  subject             VARCHAR(100)  NULL,
  rolesToBroadcast    INTEGER       NOT NULL,
154 155
  useReservedNick     INTEGER       NOT NULL,
  canChangeNick       INTEGER       NOT NULL,
156
  canRegister         INTEGER       NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
157 158 159 160 161
  CONSTRAINT mucRoom__pk PRIMARY KEY (name)
);

CREATE INDEX mucRoom_roomID_idx ON mucRoom(roomID);

162 163 164 165 166 167 168
CREATE TABLE mucRoomProp (
  roomID                INTEGER         NOT NULL,
  name                  VARCHAR(100)    NOT NULL,
  propValue             TEXT            NOT NULL,
  CONSTRAINT mucRoomProp_pk PRIMARY KEY (roomID, name)
);

Gaston Dombiak's avatar
Gaston Dombiak committed
169 170
CREATE TABLE mucAffiliation (
  roomID              INTEGER        NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
171
  jid                 VARCHAR(1024)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
172 173 174 175 176 177
  affiliation         INTEGER        NOT NULL,
  CONSTRAINT mucAffiliation__pk PRIMARY KEY (roomID,jid)
);

CREATE TABLE mucMember (
  roomID              INTEGER        NOT NULL,
178
  jid                 VARCHAR(1024)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
179
  nickname            VARCHAR(255)   NULL,
180 181 182 183 184
  firstName           VARCHAR(100)  NULL,
  lastName            VARCHAR(100)  NULL,
  url                 VARCHAR(100)  NULL,
  email               VARCHAR(100)  NULL,
  faqentry            VARCHAR(100)  NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
185 186 187 188 189
  CONSTRAINT mucMember__pk PRIMARY KEY (roomID,jid)
);

CREATE TABLE mucConversationLog (
  roomID              INTEGER        NOT NULL,
Matt Tucker's avatar
Matt Tucker committed
190
  sender              VARCHAR(1024)  NOT NULL,
Gaston Dombiak's avatar
Gaston Dombiak committed
191 192 193 194 195
  nickname            VARCHAR(255)   NULL,
  time                CHAR(15)       NOT NULL,
  subject             VARCHAR(255)   NULL,
  body                TEXT           NULL
);
196
CREATE INDEX mucLog_time_idx ON mucConversationLog (time);
Matt Tucker's avatar
Matt Tucker committed
197 198 199 200 201 202 203

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

204
INSERT INTO jiveVersion (majorVersion, minorVersion) VALUES (2, 2);
Matt Tucker's avatar
Matt Tucker committed
205

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