Updated DDL for Postgresql, improved index definitions
This commit is contained in:
parent
65abe8a4cb
commit
23a72f5750
4 changed files with 31 additions and 5 deletions
|
@ -19,6 +19,7 @@ CREATE TABLE `calendars` (
|
||||||
`color` varchar(8) NOT NULL,
|
`color` varchar(8) NOT NULL,
|
||||||
`showalarms` tinyint(1) NOT NULL DEFAULT '1',
|
`showalarms` tinyint(1) NOT NULL DEFAULT '1',
|
||||||
PRIMARY KEY(`calendar_id`),
|
PRIMARY KEY(`calendar_id`),
|
||||||
|
INDEX `user_name_idx` (`user_id`, `name`),
|
||||||
CONSTRAINT `fk_calendars_user_id` FOREIGN KEY (`user_id`)
|
CONSTRAINT `fk_calendars_user_id` FOREIGN KEY (`user_id`)
|
||||||
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
@ -45,8 +46,9 @@ CREATE TABLE `events` (
|
||||||
`attendees` text DEFAULT NULL,
|
`attendees` text DEFAULT NULL,
|
||||||
`notifyat` datetime DEFAULT NULL,
|
`notifyat` datetime DEFAULT NULL,
|
||||||
PRIMARY KEY(`event_id`),
|
PRIMARY KEY(`event_id`),
|
||||||
INDEX `uid_idx` (`uid`,`calendar_id`),
|
INDEX `uid_idx` (`uid`),
|
||||||
INDEX `recurrence_idx` (`recurrence_id`),
|
INDEX `recurrence_idx` (`recurrence_id`),
|
||||||
|
INDEX `calendar_notify_idx` (`calendar_id`,`notifyat`),
|
||||||
CONSTRAINT `fk_events_calendar_id` FOREIGN KEY (`calendar_id`)
|
CONSTRAINT `fk_events_calendar_id` FOREIGN KEY (`calendar_id`)
|
||||||
REFERENCES `calendars`(`calendar_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `calendars`(`calendar_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
@ -71,7 +73,7 @@ CREATE TABLE `itipinvitations` (
|
||||||
`expires` DATETIME DEFAULT NULL,
|
`expires` DATETIME DEFAULT NULL,
|
||||||
`cancelled` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
`cancelled` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
PRIMARY KEY(`token`),
|
PRIMARY KEY(`token`),
|
||||||
INDEX `uid_idx` (`event_uid`,`user_id`),
|
INDEX `uid_idx` (`user_id`,`event_uid`),
|
||||||
CONSTRAINT `fk_itipinvitations_user_id` FOREIGN KEY (`user_id`)
|
CONSTRAINT `fk_itipinvitations_user_id` FOREIGN KEY (`user_id`)
|
||||||
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
|
|
@ -30,6 +30,8 @@ CREATE TABLE calendars (
|
||||||
PRIMARY KEY (calendar_id)
|
PRIMARY KEY (calendar_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE INDEX calendars_user_id_idx ON calendars (user_id, name);
|
||||||
|
|
||||||
|
|
||||||
CREATE SEQUENCE event_ids
|
CREATE SEQUENCE event_ids
|
||||||
INCREMENT BY 1
|
INCREMENT BY 1
|
||||||
|
@ -62,6 +64,10 @@ CREATE TABLE events (
|
||||||
PRIMARY KEY (event_id)
|
PRIMARY KEY (event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE INDEX events_calendar_id_notifyat_idx ON events (calendar_id, notifyat);
|
||||||
|
CREATE INDEX events_uid_idx ON events (uid);
|
||||||
|
CREATE INDEX events_recurrence_id_idx ON events (recurrence_id);
|
||||||
|
|
||||||
|
|
||||||
CREATE SEQUENCE attachment_ids
|
CREATE SEQUENCE attachment_ids
|
||||||
INCREMENT BY 1
|
INCREMENT BY 1
|
||||||
|
@ -79,3 +85,19 @@ CREATE TABLE attachments (
|
||||||
data text NOT NULL DEFAULT '',
|
data text NOT NULL DEFAULT '',
|
||||||
PRIMARY KEY (attachment_id)
|
PRIMARY KEY (attachment_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE INDEX attachments_user_id_idx ON attachments (user_id);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE itipinvitations (
|
||||||
|
token varchar(64) NOT NULL,
|
||||||
|
event_uid varchar(255) NOT NULL,
|
||||||
|
user_id integer NOT NULL
|
||||||
|
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
event TEXT NOT NULL,
|
||||||
|
expires timestamp without time zone DEFAULT NULL,
|
||||||
|
cancelled smallint NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (token)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX itipinvitations_user_id_event_uid_idx ON itipinvitations (user_id, event_uid);
|
||||||
|
|
|
@ -70,5 +70,5 @@ CREATE TABLE itipinvitations (
|
||||||
REFERENCES users(user_id)
|
REFERENCES users(user_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX ix_itipinvitations_uid ON itipinvitations(event_uid,user_id);
|
CREATE INDEX ix_itipinvitations_uid ON itipinvitations(user_id, event_uid);
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,8 @@ class calendar_itip
|
||||||
if ($stored[$base])
|
if ($stored[$base])
|
||||||
return $token;
|
return $token;
|
||||||
|
|
||||||
|
// @TODO: REPLACE works only with MySQL
|
||||||
|
|
||||||
$query = $this->rc->db->query(
|
$query = $this->rc->db->query(
|
||||||
"REPLACE INTO itipinvitations
|
"REPLACE INTO itipinvitations
|
||||||
(token, event_uid, user_id, event, expires)
|
(token, event_uid, user_id, event, expires)
|
||||||
|
|
Loading…
Add table
Reference in a new issue