61 lines
2.3 KiB
SQL
61 lines
2.3 KiB
SQL
CREATE TABLE `contexts` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`name` text NOT NULL,
|
|
`type` text NOT NULL,
|
|
`sort_order` integer DEFAULT 0 NOT NULL,
|
|
`meta` text,
|
|
`archived_at` text,
|
|
`updated_at` text NOT NULL,
|
|
`deleted_at` text,
|
|
`version` integer DEFAULT 1 NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `contexts_updated_at_idx` ON `contexts` (`updated_at`);--> statement-breakpoint
|
|
CREATE TABLE `history_entries` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`topic_id` text NOT NULL,
|
|
`date` text NOT NULL,
|
|
`text` text NOT NULL,
|
|
`sort_order` integer DEFAULT 0 NOT NULL,
|
|
`linked_context_id` text,
|
|
`done_at` text,
|
|
`updated_at` text NOT NULL,
|
|
`deleted_at` text,
|
|
`version` integer DEFAULT 1 NOT NULL,
|
|
FOREIGN KEY (`topic_id`) REFERENCES `topics`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `history_entries_updated_at_idx` ON `history_entries` (`updated_at`);--> statement-breakpoint
|
|
CREATE INDEX `history_entries_topic_id_idx` ON `history_entries` (`topic_id`);--> statement-breakpoint
|
|
CREATE TABLE `ratings` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`topic_id` text NOT NULL,
|
|
`history_entry_id` text NOT NULL,
|
|
`person_name` text NOT NULL,
|
|
`value` integer NOT NULL,
|
|
`comment` text,
|
|
`updated_at` text NOT NULL,
|
|
`deleted_at` text,
|
|
`version` integer DEFAULT 1 NOT NULL,
|
|
FOREIGN KEY (`topic_id`) REFERENCES `topics`(`id`) ON UPDATE no action ON DELETE no action,
|
|
FOREIGN KEY (`history_entry_id`) REFERENCES `history_entries`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `ratings_updated_at_idx` ON `ratings` (`updated_at`);--> statement-breakpoint
|
|
CREATE INDEX `ratings_topic_id_idx` ON `ratings` (`topic_id`);--> statement-breakpoint
|
|
CREATE TABLE `topics` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`context_id` text NOT NULL,
|
|
`title` text NOT NULL,
|
|
`status` text DEFAULT 'active' NOT NULL,
|
|
`snooze_until` text,
|
|
`sort_order` integer DEFAULT 0 NOT NULL,
|
|
`is_new` integer DEFAULT true NOT NULL,
|
|
`updated_at` text NOT NULL,
|
|
`deleted_at` text,
|
|
`version` integer DEFAULT 1 NOT NULL,
|
|
FOREIGN KEY (`context_id`) REFERENCES `contexts`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `topics_updated_at_idx` ON `topics` (`updated_at`);--> statement-breakpoint
|
|
CREATE INDEX `topics_context_id_idx` ON `topics` (`context_id`); |