summaryrefslogtreecommitdiff
path: root/docs/SQL/oracle.initial.sql
blob: 1ac4227655851b9d4ab97ec95d83ca747787dc61 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
CREATE TABLE "syncroton_policy" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "name" varchar(255) NOT NULL,
    "description" varchar(255) DEFAULT NULL,
    "policy_key" varchar(64) NOT NULL,
    "json_policy" clob DEFAULT NULL
);

CREATE TABLE "syncroton_device" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "deviceid" varchar(64) NOT NULL,
    "devicetype" varchar(64) NOT NULL,
    "owner_id" varchar(40) NOT NULL,
    "acsversion" varchar(40) NOT NULL,
    "policykey" varchar(64) DEFAULT NULL,
    "policy_id" varchar(40) DEFAULT NULL,
    "useragent" varchar(255) DEFAULT NULL,
    "imei" varchar(255) DEFAULT NULL,
    "model" varchar(255) DEFAULT NULL,
    "friendlyname" varchar(255) DEFAULT NULL,
    "os" varchar(255) DEFAULT NULL,
    "oslanguage" varchar(255) DEFAULT NULL,
    "phonenumber" varchar(255) DEFAULT NULL,
    "pinglifetime" integer DEFAULT NULL,
    "remotewipe" integer DEFAULT 0,
    "pingfolder" clob DEFAULT NULL,
    "lastsynccollection" clob DEFAULT NULL,
    "lastping" timestamp DEFAULT NULL,
    "contactsfilter_id" varchar(40) DEFAULT NULL,
    "calendarfilter_id" varchar(40) DEFAULT NULL,
    "tasksfilter_id" varchar(40) DEFAULT NULL,
    "emailfilter_id" varchar(40) DEFAULT NULL
);

CREATE UNIQUE INDEX "syncroton_device_owner_id_idx" ON "syncroton_device" ("owner_id", "deviceid");


CREATE TABLE "syncroton_folder" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "device_id" varchar(40) NOT NULL
        REFERENCES "syncroton_device" ("id") ON DELETE CASCADE,
    "class" varchar(64) NOT NULL,
    "folderid" varchar(254) NOT NULL,
    "parentid" varchar(254) DEFAULT NULL,
    "displayname" varchar(254) NOT NULL,
    "type" integer NOT NULL,
    "creation_time" timestamp NOT NULL,
    "lastfiltertype" integer DEFAULT NULL,
    "supportedfields" clob DEFAULT NULL
);

CREATE UNIQUE INDEX "syncroton_folder_device_id_idx" ON "syncroton_folder" ("device_id", "class", "folderid");


CREATE TABLE "syncroton_synckey" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "device_id" varchar(40) NOT NULL
        REFERENCES "syncroton_device" ("id") ON DELETE CASCADE,
    "type" varchar(64) DEFAULT NULL,
    "counter" integer DEFAULT 0 NOT NULL,
    "lastsync" timestamp DEFAULT NULL,
    "pendingdata" clob
);

CREATE UNIQUE INDEX "syncroton_synckey_device_idx" ON "syncroton_synckey" ("device_id", "type", "counter");

CREATE TABLE "syncroton_content" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "device_id" varchar(40) NOT NULL
        REFERENCES "syncroton_device" ("id") ON DELETE CASCADE,
    "folder_id" varchar(40) NOT NULL,
    "contentid" varchar(128) NOT NULL,
    "creation_time" timestamp DEFAULT NULL,
    "creation_synckey" integer NOT NULL,
    "is_deleted" smallint DEFAULT 0
);

CREATE UNIQUE INDEX "syncroton_content_device_idx" ON "syncroton_content" ("device_id", "folder_id", "contentid");

CREATE TABLE "syncroton_data" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "class" varchar(40) NOT NULL,
    "folder_id" varchar(40) NOT NULL,
    "data" clob
);

CREATE TABLE "syncroton_data_folder" (
    "id" varchar(40) NOT NULL PRIMARY KEY,
    "type" integer NOT NULL,
    "name" varchar(255) NOT NULL,
    "owner_id" varchar(40) NOT NULL,
    "parent_id" varchar(40) DEFAULT NULL
);

CREATE TABLE "syncroton_modseq" (
    "device_id" varchar(40) NOT NULL
        REFERENCES "syncroton_device" ("id") ON DELETE CASCADE,
    "folder_id" varchar(40) NOT NULL,
    "synctime" timestamp NOT NULL,
    "data" clob,
    PRIMARY KEY ("device_id", "folder_id", "synctime")
);

CREATE TABLE "syncroton_relations_state" (
    "device_id" varchar(40) NOT NULL
        REFERENCES "syncroton_device" ("id") ON DELETE CASCADE,
    "folder_id" varchar(40) NOT NULL,
    "synctime" timestamp NOT NULL,
    "data" clob,
    PRIMARY KEY ("device_id", "folder_id", "synctime")
);

INSERT INTO "system" ("name", "value") VALUES ('syncroton-version', '2014101300');