calendars_9.3.5.sql 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. CREATE TABLE _SqliteDatabaseProperties (key TEXT,
  2. value TEXT,
  3. UNIQUE(key));
  4. CREATE TABLE sqlite_sequence(name,seq);
  5. CREATE TABLE Identity (display_name TEXT,
  6. address TEXT,
  7. first_name TEXT,
  8. last_name TEXT,
  9. UNIQUE (display_name,
  10. address,
  11. first_name,
  12. last_name));
  13. CREATE TABLE ExceptionDate (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  14. owner_id INTEGER,
  15. date REAL,
  16. sync_order INTEGER);
  17. CREATE INDEX ExceptionDateOwnerId on ExceptionDate(owner_id);
  18. CREATE TABLE Category (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  19. name TEXT,
  20. entity_type INTEGER,
  21. hidden INTEGER);
  22. CREATE UNIQUE INDEX CategoryNameAndType on Category(name,
  23. entity_type);
  24. CREATE TABLE CategoryLink (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  25. owner_id INTEGER,
  26. category_id INTEGER);
  27. CREATE INDEX OwnerID on CategoryLink(owner_id);
  28. CREATE TABLE ResourceChange (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  29. notification_id INTEGER,
  30. calendar_id INTEGER,
  31. calendar_item_id INTEGER,
  32. identity_id INTEGER,
  33. change_type INTEGER,
  34. timestamp REAL,
  35. changed_properties INTEGER,
  36. create_count INTEGER,
  37. update_count INTEGER,
  38. delete_count INTEGER,
  39. deleted_summary TEXT,
  40. deleted_start_date REAL,
  41. alerted INTEGER,
  42. public_status INTEGER);
  43. CREATE INDEX ResourceChangeNotificationID on ResourceChange(notification_id);
  44. CREATE INDEX ResourceChangeCalendarID on ResourceChange(calendar_item_id);
  45. CREATE INDEX ResourceChangeCalendarItemID on ResourceChange(calendar_item_id);
  46. CREATE INDEX ResourceChangeIdentityID on ResourceChange(identity_id);
  47. CREATE TRIGGER delete_notification_calendar AFTER DELETE ON ResourceChange
  48. BEGIN
  49. DELETE FROM ResourceChange WHERE calendar_id NOT IN (SELECT ROWID FROM Calendar);
  50. END;
  51. CREATE TABLE OccurrenceCache (day REAL,
  52. event_id INTEGER,
  53. calendar_id INTEGER,
  54. store_id INTEGER,
  55. occurrence_date REAL,
  56. occurrence_start_date REAL,
  57. occurrence_end_date REAL);
  58. CREATE TABLE OccurrenceCacheDays (calendar_id INTEGER,
  59. store_id INTEGER,
  60. day REAL,
  61. count INTEGER,
  62. PRIMARY KEY (calendar_id,
  63. day));
  64. CREATE TRIGGER update_cache_days_after_delete AFTER DELETE ON OccurrenceCache
  65. BEGIN
  66. UPDATE OccurrenceCacheDays SET count = count - 1 WHERE day = OLD.day AND calendar_id = OLD.calendar_id;UPDATE OccurrenceCacheDays SET count = count - 1 WHERE day = OLD.day AND calendar_id = -2;
  67. END;
  68. CREATE TRIGGER update_cache_days_after_insert AFTER INSERT ON OccurrenceCache
  69. BEGIN
  70. REPLACE INTO OccurrenceCacheDays VALUES (NEW.calendar_id,
  71. NEW.store_id,
  72. NEW.day,
  73. 1 + IFNULL((SELECT count FROM OccurrenceCacheDays WHERE day = NEW.day AND calendar_id = NEW.calendar_id),
  74. 0));
  75. REPLACE INTO OccurrenceCacheDays VALUES (-2,
  76. -2,
  77. NEW.day,
  78. 1 + IFNULL((SELECT count FROM OccurrenceCacheDays WHERE day = NEW.day AND calendar_id = -2),
  79. 0));
  80. END;
  81. CREATE TRIGGER update_cache_days_after_update AFTER UPDATE OF day ON OccurrenceCache
  82. BEGIN
  83. REPLACE INTO OccurrenceCacheDays VALUES (NEW.calendar_id,
  84. NEW.store_id,
  85. NEW.day,
  86. 1 + IFNULL((SELECT count FROM OccurrenceCacheDays WHERE day = NEW.day AND calendar_id = NEW.calendar_id),
  87. 0));
  88. REPLACE INTO OccurrenceCacheDays VALUES (-2,
  89. -2,
  90. NEW.day,
  91. 1 + IFNULL((SELECT count FROM OccurrenceCacheDays WHERE day = NEW.day AND calendar_id = -2),
  92. 0));
  93. UPDATE OccurrenceCacheDays SET count = count - 1 WHERE day = OLD.day AND calendar_id = OLD.calendar_id;UPDATE OccurrenceCacheDays SET count = count - 1 WHERE day = OLD.day AND calendar_id = -2;
  94. END;
  95. CREATE TABLE ScheduledTaskCache (day REAL,
  96. date_for_sorting REAL,
  97. completed INTEGER,
  98. task_id INTEGER,
  99. count INTEGER,
  100. PRIMARY KEY (day,
  101. task_id));
  102. CREATE TRIGGER update_task_cache_count_after_insert AFTER INSERT ON ScheduledTaskCache
  103. BEGIN
  104. REPLACE INTO ScheduledTaskCache VALUES (NEW.day,
  105. NULL,
  106. NULL,
  107. -2,
  108. 1 + IFNULL((SELECT count FROM ScheduledTaskCache WHERE day = NEW.day AND task_id = -2),
  109. 0));
  110. END;
  111. CREATE TRIGGER update_task_cache_count_after_update AFTER UPDATE OF day ON ScheduledTaskCache
  112. BEGIN
  113. UPDATE ScheduledTaskCache SET count = count - 1 WHERE day = OLD.day AND task_id = -2;
  114. REPLACE INTO ScheduledTaskCache VALUES (NEW.day,
  115. NULL,
  116. NULL,
  117. -2,
  118. IFNULL((SELECT count FROM ScheduledTaskCache WHERE day = NEW.day AND task_id = -2),
  119. 0));
  120. DELETE FROM ScheduledTaskCache WHERE day = OLD.day AND count = 0;
  121. END;
  122. CREATE TRIGGER update_task_cache_days_after_delete AFTER DELETE ON ScheduledTaskCache
  123. BEGIN
  124. UPDATE ScheduledTaskCache SET count = count - 1 WHERE day = OLD.day AND task_id = -2;
  125. DELETE FROM ScheduledTaskCache WHERE day = OLD.day AND count = 0;
  126. END;
  127. CREATE INDEX ScheduledTaskCacheDayTaskId on ScheduledTaskCache(day);
  128. CREATE INDEX ScheduledTaskCacheTaskId on ScheduledTaskCache(task_id);
  129. CREATE INDEX OccurrenceCacheDayEventIdOccurrenceDate on OccurrenceCache(day,
  130. event_id,
  131. occurrence_date);
  132. CREATE INDEX OccurrenceCacheOccurrenceDateEventId on OccurrenceCache(occurrence_date,
  133. event_id);
  134. CREATE INDEX OccurrenceCacheCalendarId on OccurrenceCache(calendar_id);
  135. CREATE INDEX OccurrenceCacheDaysCount on OccurrenceCacheDays(count);
  136. CREATE INDEX OccurrenceCacheDaysDayCalendarId on OccurrenceCacheDays(day,
  137. calendar_id);
  138. CREATE TABLE Store (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  139. name TEXT,
  140. default_alarm_offset INTEGER,
  141. type INTEGER,
  142. constraint_path TEXT,
  143. disabled INTEGER,
  144. external_id TEXT,
  145. persistent_id TEXT,
  146. flags INTEGER,
  147. creator_bundle_id TEXT,
  148. creator_code_signing_identity TEXT,
  149. only_creator_can_modify INTEGER,
  150. external_mod_tag TEXT,
  151. preferred_event_private_value INTEGER,
  152. strictest_event_private_value INTEGER);
  153. CREATE TABLE StoreChanges (record INTEGER,
  154. type INTEGER,
  155. sequence_number INTEGER);
  156. CREATE TRIGGER delete_store_members AFTER DELETE ON Store
  157. BEGIN
  158. DELETE FROM Calendar WHERE store_id = OLD.ROWID;
  159. END;
  160. CREATE TRIGGER delete_store_changes AFTER DELETE ON Store
  161. BEGIN
  162. DELETE FROM CalendarChanges WHERE store_id = OLD.ROWID;DELETE FROM CalendarItemChanges WHERE store_id = OLD.ROWID;DELETE FROM AlarmChanges WHERE store_id = OLD.ROWID;DELETE FROM RecurrenceChanges WHERE store_id = OLD.ROWID;DELETE FROM ParticipantChanges WHERE store_id = OLD.ROWID;
  163. END;
  164. CREATE TABLE Calendar (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  165. store_id INTEGER,
  166. title TEXT,
  167. flags INTEGER,
  168. color TEXT,
  169. symbolic_color_name TEXT,
  170. color_is_display INTEGER,
  171. type TEXT,
  172. supported_entity_types INTEGER,
  173. external_id TEXT,
  174. external_mod_tag TEXT,
  175. external_id_tag TEXT,
  176. external_rep BLOB,
  177. display_order INTEGER,
  178. UUID TEXT,
  179. shared_owner_name TEXT,
  180. shared_owner_email TEXT,
  181. sharing_status INTEGER,
  182. sharing_invitation_response INTEGER,
  183. published_URL TEXT,
  184. is_published INTEGER,
  185. invitation_status INTEGER,
  186. sync_token TEXT,
  187. self_identity_id INTEGER,
  188. self_identity_email TEXT,
  189. owner_identity_id INTEGER,
  190. owner_identity_email TEXT,
  191. notes TEXT,
  192. bulk_requests BLOB,
  193. subcal_account_id TEXT,
  194. push_key TEXT,
  195. digest BLOB);
  196. CREATE TABLE CalendarChanges (record INTEGER,
  197. type INTEGER,
  198. sequence_number INTEGER,
  199. store_id INTEGER,
  200. flags INTEGER,
  201. external_id TEXT,
  202. external_id_tag TEXT,
  203. UUID TEXT);
  204. CREATE INDEX CalendarExternalId on Calendar(external_id);
  205. CREATE INDEX CalendarStoreId on Calendar(store_id);
  206. CREATE INDEX CalendarUUID on Calendar(UUID);
  207. CREATE INDEX CalendarSelfIdentityId on Calendar(self_identity_id);
  208. CREATE TRIGGER delete_calendar_members AFTER DELETE ON Calendar
  209. BEGIN
  210. DELETE FROM OccurrenceCacheDays where calendar_id = OLD.ROWID;DELETE FROM OccurrenceCache where calendar_id = OLD.ROWID;DELETE FROM CalendarItem WHERE calendar_id = OLD.ROWID;DELETE FROM OccurrenceCacheDays WHERE count = 0;DELETE FROM Notification WHERE calendar_id = OLD.ROWID; DELETE FROM sharee where owner_id = OLD.ROWID;DELETE FROM Alarm WHERE calendar_owner_id = OLD.ROWID;
  211. END;
  212. CREATE TABLE Participant (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  213. entity_type INTEGER,
  214. type INTEGER,
  215. status INTEGER,
  216. pending_status INTEGER,
  217. role INTEGER,
  218. identity_id INTEGER,
  219. owner_id INTEGER,
  220. external_rep BLOB,
  221. UUID TEXT,
  222. email TEXT,
  223. is_self INTEGER,
  224. comment TEXT,
  225. schedule_agent INTEGER,
  226. flags INTEGER,
  227. last_modified REAL,
  228. comment_last_modified REAL);
  229. CREATE TABLE ParticipantChanges (record INTEGER,
  230. type INTEGER,
  231. sequence_number INTEGER,
  232. entity_type INTEGER,
  233. owner_id INTEGER,
  234. UUID TEXT,
  235. email TEXT,
  236. comment TEXT,
  237. store_id INTEGER,
  238. calendar_id INTEGER);
  239. CREATE INDEX ParticipantUUID on Participant(UUID);
  240. CREATE INDEX ParticipantEntityType on Participant(entity_type);
  241. CREATE INDEX ParticipantOwnerId on Participant(owner_id);
  242. CREATE INDEX ParticipantIdentityId on Participant(identity_id);
  243. CREATE TABLE Location (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  244. title TEXT,
  245. address TEXT,
  246. latitude INTEGER,
  247. longitude INTEGER,
  248. reference_frame INTEGER,
  249. address_book_id TEXT,
  250. mapkit_handle BLOB,
  251. radius INTEGER,
  252. routing TEXT,
  253. item_owner_id INTEGER,
  254. alarm_owner_id INTEGER);
  255. CREATE INDEX LocationOwnerItemId on Location(item_owner_id);
  256. CREATE TABLE CalendarItem (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  257. summary TEXT,
  258. location_id INTEGER,
  259. client_location_id INTEGER,
  260. description TEXT,
  261. start_date REAL,
  262. start_tz TEXT,
  263. end_date REAL,
  264. end_tz TEXT,
  265. all_day INTEGER,
  266. calendar_id INTEGER,
  267. orig_item_id INTEGER,
  268. orig_date REAL,
  269. organizer_id INTEGER,
  270. self_attendee_id INTEGER,
  271. status INTEGER,
  272. invitation_status INTEGER,
  273. availability INTEGER,
  274. privacy_level INTEGER,
  275. url TEXT,
  276. last_modified REAL,
  277. sequence_num INTEGER,
  278. birthday_id INTEGER,
  279. modified_properties INTEGER,
  280. external_tracking_status INTEGER,
  281. external_id TEXT,
  282. external_mod_tag TEXT,
  283. unique_identifier TEXT,
  284. external_schedule_id TEXT,
  285. external_rep BLOB,
  286. response_comment TEXT,
  287. last_synced_response_comment TEXT,
  288. hidden INTEGER,
  289. has_recurrences INTEGER,
  290. has_attendees INTEGER,
  291. UUID TEXT,
  292. entity_type INTEGER,
  293. priority INTEGER,
  294. due_date REAL,
  295. due_tz TEXT,
  296. due_all_day INTEGER,
  297. completion_date REAL,
  298. creation_date REAL,
  299. conference TEXT,
  300. app_link BLOB,
  301. display_order INTEGER,
  302. created_by_id INTEGER,
  303. modified_by_id INTEGER,
  304. shared_item_created_date REAL,
  305. shared_item_created_tz TEXT,
  306. shared_item_modified_date REAL,
  307. shared_item_modified_tz TEXT,
  308. invitation_changed_properties INTEGER,
  309. default_alarm_removed INTEGER,
  310. phantom_master INTEGER,
  311. participation_status_modified_date REAL,
  312. calendar_scale TEXT,
  313. travel_time INTEGER,
  314. travel_advisory_behavior INTEGER,
  315. start_location_id INTEGER,
  316. suggested_event_info_id INTEGER,
  317. first_alert_date REAL);
  318. CREATE TABLE CalendarItemChanges (record INTEGER,
  319. type INTEGER,
  320. sequence_number INTEGER,
  321. calendar_id INTEGER,
  322. external_id TEXT,
  323. unique_identifier TEXT,
  324. UUID TEXT,
  325. entity_type INTEGER,
  326. store_id INTEGER,
  327. has_dirty_instance_attributes INTEGER,
  328. old_calendar_id INTEGER,
  329. old_external_id TEXT);
  330. CREATE INDEX EventStatus on CalendarItem(status);
  331. CREATE INDEX EventHiddenEndDateStartDate on CalendarItem(hidden,
  332. end_date,
  333. start_date);
  334. CREATE INDEX EventExternalIdCalId on CalendarItem(external_id,
  335. calendar_id);
  336. CREATE INDEX EventExternalUniqueIdentifierCalId on CalendarItem(unique_identifier,
  337. calendar_id);
  338. CREATE INDEX EventUUID on CalendarItem(UUID);
  339. CREATE INDEX CalendarItemDueDate on CalendarItem(due_date);
  340. CREATE INDEX CalendarItemEntityTypeCompletionDate on CalendarItem(entity_type,
  341. completion_date);
  342. CREATE INDEX CalendarItemEntityTypeCalendarIdCompletionDateCreationDate on CalendarItem(entity_type,
  343. calendar_id,
  344. completion_date,
  345. creation_date);
  346. CREATE INDEX EventInvitationStatus on CalendarItem(invitation_status);
  347. CREATE INDEX CalendarItemOriginalItemId on CalendarItem(orig_item_id);
  348. CREATE INDEX CalendarItemOriginalDate on CalendarItem(orig_date);
  349. CREATE TRIGGER delete_event_alarms_recurs AFTER DELETE ON CalendarItem
  350. BEGIN
  351. DELETE FROM Location WHERE item_owner_id = OLD.ROWID;DELETE FROM Alarm WHERE calendaritem_owner_id = OLD.ROWID;DELETE FROM Recurrence WHERE owner_id = OLD.ROWID;DELETE FROM Participant WHERE owner_id = OLD.ROWID;DELETE FROM ExceptionDate WHERE owner_id = OLD.ROWID;DELETE FROM OccurrenceCache WHERE event_id = OLD.ROWID;DELETE FROM OccurrenceCacheDays WHERE count = 0;DELETE FROM Attachment WHERE owner_id = OLD.ROWID;DELETE FROM ScheduledTaskCache WHERE task_id = OLD.ROWID;DELETE FROM EventAction WHERE event_id = OLD.ROWID;DELETE FROM SuggestedEventInfo WHERE ROWID = OLD.suggested_event_info_id;
  352. END;
  353. CREATE TABLE Alarm (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  354. trigger_date REAL,
  355. trigger_interval INTEGER,
  356. type INTEGER,
  357. calendaritem_owner_id INTEGER,
  358. calendar_owner_id INTEGER,
  359. external_id TEXT,
  360. external_mod_tag TEXT,
  361. external_id_tag TEXT,
  362. external_rep BLOB,
  363. UUID TEXT,
  364. proximity INTEGER,
  365. disabled INTEGER,
  366. location_id INTEGER,
  367. acknowledgedDate REAL,
  368. default_alarm INTEGER,
  369. orig_alarm_id INTEGER);
  370. CREATE TABLE AlarmChanges (record INTEGER,
  371. type INTEGER,
  372. sequence_number INTEGER,
  373. calendaritem_owner_id INTEGER,
  374. calendar_owner_id INTEGER,
  375. external_id TEXT,
  376. store_id INTEGER,
  377. calendar_id INTEGER,
  378. UUID TEXT);
  379. CREATE INDEX AlarmExternalId on Alarm(external_id);
  380. CREATE INDEX AlarmUUID on Alarm(UUID);
  381. CREATE INDEX AlarmTriggerDate on Alarm(trigger_date);
  382. CREATE INDEX AlarmCalendarItemOwnerId on Alarm(calendaritem_owner_id);
  383. CREATE INDEX AlarmCalendarOwnerId on Alarm(calendar_owner_id);
  384. CREATE TRIGGER cascade_alarm_delete AFTER DELETE ON Alarm
  385. BEGIN
  386. DELETE FROM Location WHERE alarm_owner_id = OLD.ROWID;
  387. END;
  388. CREATE TABLE Recurrence (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  389. frequency INTEGER,
  390. interval INTEGER,
  391. week_start INTEGER,
  392. count INTEGER,
  393. cached_end_date REAL,
  394. cached_end_date_tz TEXT,
  395. end_date REAL,
  396. specifier TEXT,
  397. by_month_months INTEGER,
  398. owner_id INTEGER,
  399. external_id TEXT,
  400. external_mod_tag TEXT,
  401. external_id_tag TEXT,
  402. external_rep BLOB,
  403. UUID TEXT);
  404. CREATE TABLE RecurrenceChanges (record INTEGER,
  405. type INTEGER,
  406. sequence_number INTEGER,
  407. external_id TEXT,
  408. store_id INTEGER,
  409. event_id_tomb INTEGER,
  410. calendar_id INTEGER,
  411. end_date_tomb REAL,
  412. UUID TEXT);
  413. CREATE INDEX RecurrenceEndCountIndex on Recurrence(end_date,
  414. count);
  415. CREATE INDEX RecurrenceExternalId on Recurrence(external_id);
  416. CREATE INDEX RecurrenceOwnerIdIndex on Recurrence(owner_id);
  417. CREATE INDEX RecurrenceUUID on Recurrence(UUID);
  418. CREATE TABLE EventAction (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  419. event_id INTEGER,
  420. external_id TEXT,
  421. external_mod_tag TEXT,
  422. external_folder_id TEXT,
  423. external_schedule_id TEXT,
  424. external_rep BLOB);
  425. CREATE TABLE EventActionChanges (record INTEGER,
  426. type INTEGER,
  427. sequence_number INTEGER,
  428. event_id INTEGER,
  429. external_id TEXT,
  430. external_folder_id TEXT,
  431. external_schedule_id TEXT,
  432. store_id INTEGER,
  433. calendar_id INTEGER);
  434. CREATE INDEX EventActionEventId on EventAction(event_id);
  435. CREATE INDEX EventActionExternalId on EventAction(external_id);
  436. CREATE INDEX EventActionFolderId on EventAction(external_folder_id);
  437. CREATE TABLE Attachment (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  438. owner_id INTEGER,
  439. external_id TEXT,
  440. external_mod_tag TEXT,
  441. external_rep BLOB,
  442. url TEXT,
  443. UUID TEXT,
  444. data BLOB,
  445. format TEXT,
  446. is_binary INTEGER,
  447. filename TEXT,
  448. local_url TEXT,
  449. file_size INTEGER);
  450. CREATE TABLE AttachmentChanges (record INTEGER,
  451. type INTEGER,
  452. sequence_number INTEGER,
  453. owner_id INTEGER,
  454. external_id TEXT,
  455. external_mod_tag TEXT,
  456. UUID TEXT,
  457. store_id INTEGER,
  458. calendar_id INTEGER);
  459. CREATE INDEX AttachmentEventId on Attachment(owner_id);
  460. CREATE INDEX AttachmentUUID on Attachment(UUID);
  461. CREATE TABLE Sharee (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  462. owner_id INTEGER,
  463. external_id TEXT,
  464. external_rep BLOB,
  465. UUID TEXT,
  466. identity_id INTEGER,
  467. status INTEGER,
  468. access_level INTEGER);
  469. CREATE TABLE ShareeChanges (record INTEGER,
  470. type INTEGER,
  471. sequence_number INTEGER,
  472. owner_id INTEGER,
  473. UUID TEXT,
  474. status INTEGER,
  475. access_level INTEGER,
  476. display_name TEXT,
  477. address TEXT,
  478. store_id INTEGER,
  479. calendar_id INTEGER,
  480. first_name TEXT,
  481. last_name TEXT);
  482. CREATE INDEX ShareeUUID on Sharee(UUID);
  483. CREATE INDEX ShareeOwnerId on Sharee(owner_id);
  484. CREATE INDEX ShareeStatus on Sharee(status);
  485. CREATE INDEX ShareeAccessLevel on Sharee(access_level);
  486. CREATE INDEX ShareeIdentityId on Sharee(identity_id);
  487. CREATE TABLE Notification (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  488. entity_type INTEGER,
  489. calendar_id INTEGER,
  490. external_id TEXT,
  491. external_mod_tag TEXT,
  492. UUID TEXT,
  493. summary TEXT,
  494. creation_date REAL,
  495. last_modified REAL,
  496. status INTEGER,
  497. host_url TEXT,
  498. in_reply_to TEXT,
  499. identity_id INTEGER,
  500. alerted INTEGER);
  501. CREATE TABLE NotificationChanges (record INTEGER,
  502. type INTEGER,
  503. sequence_number INTEGER,
  504. entity_type INTEGER,
  505. calendar_id INTEGER,
  506. external_id TEXT,
  507. UUID TEXT,
  508. store_id INTEGER);
  509. CREATE INDEX NotificationUUIDCalendarId on Notification(UUID,
  510. calendar_id);
  511. CREATE INDEX NotificationEntityType on Notification(entity_type);
  512. CREATE INDEX NotificationExternalIDCalendarId on Notification(external_id,
  513. calendar_id);
  514. CREATE INDEX NotificationCalendarId on Notification(calendar_id);
  515. CREATE TRIGGER delete_resource_changes_for_notification AFTER DELETE ON Notification
  516. BEGIN
  517. DELETE FROM ResourceChange WHERE notification_id NOT IN (SELECT ROWID FROM Notification WHERE entity_type = 17 OR entity_type = 19);
  518. END;
  519. CREATE TABLE SuggestedEventInfo (ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  520. owner_id INTEGER,
  521. opaque_key TEXT,
  522. unique_key TEXT,
  523. changed_fields INTEGER,
  524. changes_acknowledged INTEGER,
  525. timestamp REAL);
  526. CREATE INDEX SuggestedEventInfoOwnerId on SuggestedEventInfo(owner_id);
  527. CREATE TABLE ClientCursor ( ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
  528. client_identifier TEXT,
  529. store_id INTEGER,
  530. latest_consumed_sequence_number INTEGER,
  531. latest_consumed_timestamp REAL,
  532. UNIQUE(client_identifier) );
  533. CREATE INDEX ClientCursorClientIdentifier ON ClientCursor(client_identifier);
  534. CREATE TABLE ClientSequence (client_identifier TEXT,
  535. sequence_number INTEGER );
  536. CREATE INDEX ClientSequenceClientIdentifier ON ClientSequence(client_identifier);
  537. CREATE TABLE ClientCursorConsumed ( client_identifier TEXT,
  538. consumed_entity_class INTEGER,
  539. consumed_entity_id INTEGER,
  540. consumed_change_id INTEGER,
  541. sequence_number INTEGER );
  542. CREATE INDEX ClientCursorConsumedClientIdentifier ON ClientCursorConsumed(client_identifier);
  543. CREATE TRIGGER delete_clientcursor_consumed AFTER DELETE ON ClientCursor BEGIN DELETE FROM ClientCursorConsumed WHERE client_identifier = OLD.client_identifier; DELETE FROM ClientSequence WHERE client_identifier = OLD.client_identifier; END;