File
Blob: drizzle/cal-dav-do/0001_low_hiroim.sql
| 1 | CREATE TABLE `calendar_changes` ( |
| 2 | `seq` integer PRIMARY KEY AUTOINCREMENT NOT NULL, |
| 3 | `calendar_id` text, |
| 4 | `href` text NOT NULL, |
| 5 | `change_type` text NOT NULL, |
| 6 | `changed_at_ms` integer NOT NULL, |
| 7 | FOREIGN KEY (`calendar_id`) REFERENCES `calendars`(`id`) ON UPDATE no action ON DELETE cascade, |
| 8 | CONSTRAINT "calendar_changes_type_check" CHECK("calendar_changes"."change_type" in ('created', 'updated', 'deleted')) |
| 9 | ); |
| 10 | --> statement-breakpoint |
| 11 | CREATE INDEX `calendar_changes_calendar_seq_idx` ON `calendar_changes` (`calendar_id`,`seq`);--> statement-breakpoint |
| 12 | CREATE INDEX `calendar_changes_changed_idx` ON `calendar_changes` (`changed_at_ms`);--> statement-breakpoint |
| 13 | CREATE INDEX `calendar_changes_href_idx` ON `calendar_changes` (`href`);--> statement-breakpoint |
| 14 | CREATE TABLE `calendar_dead_props` ( |
| 15 | `resource_kind` text NOT NULL, |
| 16 | `resource_id` text NOT NULL, |
| 17 | `ns_uri` text NOT NULL, |
| 18 | `local_name` text NOT NULL, |
| 19 | `xml_value` text NOT NULL, |
| 20 | PRIMARY KEY(`resource_kind`, `resource_id`, `ns_uri`, `local_name`), |
| 21 | CONSTRAINT "calendar_dead_props_kind_check" CHECK("calendar_dead_props"."resource_kind" in ('home', 'calendar', 'object')) |
| 22 | ); |
| 23 | --> statement-breakpoint |
| 24 | CREATE TABLE `calendar_index` ( |
| 25 | `object_id` text PRIMARY KEY NOT NULL, |
| 26 | `calendar_id` text NOT NULL, |
| 27 | `uid` text NOT NULL, |
| 28 | `component_type` text NOT NULL, |
| 29 | `dtstart_ms` integer, |
| 30 | `dtend_ms` integer, |
| 31 | `due_ms` integer, |
| 32 | `completed_ms` integer, |
| 33 | `summary` text, |
| 34 | `has_recurrence` integer DEFAULT false NOT NULL, |
| 35 | `recurrence_min_ms` integer, |
| 36 | `recurrence_max_ms` integer, |
| 37 | FOREIGN KEY (`object_id`) REFERENCES `calendar_objects`(`id`) ON UPDATE no action ON DELETE cascade, |
| 38 | FOREIGN KEY (`calendar_id`) REFERENCES `calendars`(`id`) ON UPDATE no action ON DELETE cascade, |
| 39 | CONSTRAINT "calendar_index_component_check" CHECK("calendar_index"."component_type" in ('VEVENT', 'VTODO', 'VJOURNAL')) |
| 40 | ); |
| 41 | --> statement-breakpoint |
| 42 | CREATE INDEX `calendar_index_timerange_idx` ON `calendar_index` (`calendar_id`,`component_type`,`dtstart_ms`,`dtend_ms`);--> statement-breakpoint |
| 43 | CREATE INDEX `calendar_index_due_idx` ON `calendar_index` (`calendar_id`,`due_ms`);--> statement-breakpoint |
| 44 | CREATE INDEX `calendar_index_completed_idx` ON `calendar_index` (`calendar_id`,`completed_ms`);--> statement-breakpoint |
| 45 | CREATE INDEX `calendar_index_uid_idx` ON `calendar_index` (`calendar_id`,`uid`);--> statement-breakpoint |
| 46 | CREATE INDEX `calendar_index_recurrence_idx` ON `calendar_index` (`calendar_id`,`has_recurrence`,`recurrence_min_ms`,`recurrence_max_ms`);--> statement-breakpoint |
| 47 | CREATE TABLE `calendar_objects` ( |
| 48 | `id` text PRIMARY KEY NOT NULL, |
| 49 | `calendar_id` text NOT NULL, |
| 50 | `name` text NOT NULL, |
| 51 | `uid` text NOT NULL, |
| 52 | `component_type` text NOT NULL, |
| 53 | `body` text NOT NULL, |
| 54 | `etag` text NOT NULL, |
| 55 | `size` integer NOT NULL, |
| 56 | `created_at_ms` integer NOT NULL, |
| 57 | `modified_at_ms` integer NOT NULL, |
| 58 | `version` integer DEFAULT 1 NOT NULL, |
| 59 | FOREIGN KEY (`calendar_id`) REFERENCES `calendars`(`id`) ON UPDATE no action ON DELETE cascade, |
| 60 | CONSTRAINT "calendar_objects_component_check" CHECK("calendar_objects"."component_type" in ('VEVENT', 'VTODO', 'VJOURNAL')) |
| 61 | ); |
| 62 | --> statement-breakpoint |
| 63 | CREATE UNIQUE INDEX `calendar_objects_calendar_name_unique` ON `calendar_objects` (`calendar_id`,`name`);--> statement-breakpoint |
| 64 | CREATE UNIQUE INDEX `calendar_objects_calendar_uid_unique` ON `calendar_objects` (`calendar_id`,`uid`);--> statement-breakpoint |
| 65 | CREATE INDEX `calendar_objects_calendar_modified_idx` ON `calendar_objects` (`calendar_id`,`modified_at_ms`);--> statement-breakpoint |
| 66 | CREATE INDEX `calendar_objects_component_idx` ON `calendar_objects` (`calendar_id`,`component_type`);--> statement-breakpoint |
| 67 | CREATE TABLE `calendars` ( |
| 68 | `id` text PRIMARY KEY NOT NULL, |
| 69 | `name` text NOT NULL, |
| 70 | `display_name` text NOT NULL, |
| 71 | `description` text, |
| 72 | `timezone_ical` text, |
| 73 | `color` text, |
| 74 | `order_index` integer DEFAULT 0 NOT NULL, |
| 75 | `created_at_ms` integer NOT NULL, |
| 76 | `modified_at_ms` integer NOT NULL, |
| 77 | `sync_seq` integer DEFAULT 0 NOT NULL |
| 78 | ); |
| 79 | --> statement-breakpoint |
| 80 | CREATE UNIQUE INDEX `calendars_name_unique` ON `calendars` (`name`);--> statement-breakpoint |
| 81 | CREATE INDEX `calendars_order_idx` ON `calendars` (`order_index`);--> statement-breakpoint |
| 82 | CREATE INDEX `calendars_modified_idx` ON `calendars` (`modified_at_ms`); |