aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/drivers/caldav/SQL/postgres.initial.sql
blob: f49da4ebc52b5a3b6281a1efaf09cb4d8bb06d4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
 * CalDAV Client
 *
 * @version @package_version@
 * @author Hugo Slabbert <hugo@slabnet.com>
 *
 * Copyright (C) 2014, Hugo Slabbert <hugo@slabnet.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

CREATE TYPE caldav_type AS ENUM ('vcal','vevent','vtodo','');

CREATE TABLE IF NOT EXISTS caldav_props (
  obj_id int NOT NULL,
  obj_type caldav_type NOT NULL,
  url varchar(255) NOT NULL,
  tag varchar(255) DEFAULT NULL,
  username varchar(255) DEFAULT NULL,
  pass varchar(1024) DEFAULT NULL,
  last_change timestamp without time zone DEFAULT now() NOT NULL,
  PRIMARY KEY (obj_id, obj_type)
);

CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER 
LANGUAGE plpgsql
AS
$$
BEGIN
    NEW.last_change = CURRENT_TIMESTAMP;
    RETURN NEW;
END;
$$;

CREATE TRIGGER update_timestamp
  BEFORE INSERT OR UPDATE
  ON caldav_props
  FOR EACH ROW
  EXECUTE PROCEDURE upd_timestamp();

© 2014-2024 Faster IT GmbH | imprint | privacy policy