| 1 | CREATE TABLE `members` (`id` integer PRIMARY KEY AUTOINCREMENT,`address_print` text NOT NULL,`sealed_address` blob,`sealed_time_zone` blob); |
| 2 | |
| 3 | CREATE UNIQUE INDEX `idx_members_address_print` ON `members`(`address_print`); |
| 4 | |
| 5 | CREATE TABLE `pages` (`id` integer PRIMARY KEY AUTOINCREMENT,`nonce` integer NOT NULL,`kind` text NOT NULL,`rung` text NOT NULL,`owner_id` integer NOT NULL,`revision` integer NOT NULL,`gone` numeric NOT NULL DEFAULT false,`sealed_record` blob,`created_at` datetime,`updated_at` datetime,CONSTRAINT `fk_pages_owner` FOREIGN KEY (`owner_id`) REFERENCES `members`(`id`) ON DELETE RESTRICT); |
| 6 | |
| 7 | CREATE INDEX `idx_pages_updated_at` ON `pages`(`updated_at`); |
| 8 | |
| 9 | CREATE INDEX `idx_pages_gone` ON `pages`(`gone`); |
| 10 | |
| 11 | CREATE INDEX `idx_pages_owner_id` ON `pages`(`owner_id`); |
| 12 | |
| 13 | CREATE INDEX `idx_pages_kind` ON `pages`(`kind`); |
| 14 | |
| 15 | CREATE TABLE `aliases` (`id` integer PRIMARY KEY AUTOINCREMENT,`page_id` integer NOT NULL,`sealed_title` blob,CONSTRAINT `fk_aliases_page` FOREIGN KEY (`page_id`) REFERENCES `pages`(`id`) ON DELETE CASCADE); |
| 16 | |
| 17 | CREATE INDEX `idx_aliases_page_id` ON `aliases`(`page_id`); |
| 18 | |
| 19 | CREATE TABLE `title_prints` (`print` text,`page_id` integer NOT NULL,PRIMARY KEY (`print`),CONSTRAINT `fk_title_prints_page` FOREIGN KEY (`page_id`) REFERENCES `pages`(`id`) ON DELETE CASCADE); |
| 20 | |
| 21 | CREATE INDEX `idx_title_prints_page_id` ON `title_prints`(`page_id`); |
| 22 | |
| 23 | CREATE TABLE `daily_prints` (`print` text,`page_id` integer NOT NULL,PRIMARY KEY (`print`),CONSTRAINT `fk_daily_prints_page` FOREIGN KEY (`page_id`) REFERENCES `pages`(`id`) ON DELETE CASCADE); |
| 24 | |
| 25 | CREATE UNIQUE INDEX `idx_daily_prints_page_id` ON `daily_prints`(`page_id`); |
| 26 | |
| 27 | CREATE TABLE `revisions` (`page_id` integer,`revision` integer,`at` datetime NOT NULL,`actor_id` integer NOT NULL,`sealed_record` blob,PRIMARY KEY (`page_id`,`revision`),CONSTRAINT `fk_revisions_page` FOREIGN KEY (`page_id`) REFERENCES `pages`(`id`) ON DELETE CASCADE); |
| 28 | |
| 29 | CREATE INDEX `idx_revisions_at` ON `revisions`(`at`); |
| 30 | |
| 31 | CREATE TABLE `drafts` (`id` integer PRIMARY KEY AUTOINCREMENT,`page_id` integer,`daily_print` text,`person_id` integer,`base_revision` integer,`version` integer NOT NULL,`sealed_record` blob,`updated_at` datetime); |
| 32 | |
| 33 | CREATE INDEX `idx_drafts_updated_at` ON `drafts`(`updated_at`); |
| 34 | |
| 35 | CREATE UNIQUE INDEX `draft_day` ON `drafts`(`daily_print`,`person_id`); |
| 36 | |
| 37 | CREATE UNIQUE INDEX `draft_page` ON `drafts`(`page_id`,`person_id`); |
| 38 | |
| 39 | CREATE TABLE `events` (`id` integer PRIMARY KEY AUTOINCREMENT,`nonce` integer NOT NULL,`at` datetime NOT NULL,`actor_id` integer NOT NULL,`object_kind` text NOT NULL,`object_id` integer NOT NULL,`verb` text NOT NULL,`revision` integer NOT NULL); |
| 40 | |
| 41 | CREATE INDEX `idx_events_object_id` ON `events`(`object_id`); |
| 42 | |
| 43 | CREATE INDEX `idx_events_actor_id` ON `events`(`actor_id`); |
| 44 | |
| 45 | CREATE INDEX `idx_events_at` ON `events`(`at`); |
| 46 | |
| 47 | |