mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-25 23:35:17 +00:00
Co-authored-by: Github Action <action@github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev>
90 lines
3.1 KiB
SQL
90 lines
3.1 KiB
SQL
CREATE TABLE `project` (
|
|
`id` text PRIMARY KEY,
|
|
`worktree` text NOT NULL,
|
|
`vcs` text,
|
|
`name` text,
|
|
`icon_url` text,
|
|
`icon_color` text,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
`time_initialized` integer,
|
|
`sandboxes` text NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `message` (
|
|
`id` text PRIMARY KEY,
|
|
`session_id` text NOT NULL,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
`data` text NOT NULL,
|
|
CONSTRAINT `fk_message_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `part` (
|
|
`id` text PRIMARY KEY,
|
|
`message_id` text NOT NULL,
|
|
`session_id` text NOT NULL,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
`data` text NOT NULL,
|
|
CONSTRAINT `fk_part_message_id_message_id_fk` FOREIGN KEY (`message_id`) REFERENCES `message`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `permission` (
|
|
`project_id` text PRIMARY KEY,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
`data` text NOT NULL,
|
|
CONSTRAINT `fk_permission_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `session` (
|
|
`id` text PRIMARY KEY,
|
|
`project_id` text NOT NULL,
|
|
`parent_id` text,
|
|
`slug` text NOT NULL,
|
|
`directory` text NOT NULL,
|
|
`title` text NOT NULL,
|
|
`version` text NOT NULL,
|
|
`share_url` text,
|
|
`summary_additions` integer,
|
|
`summary_deletions` integer,
|
|
`summary_files` integer,
|
|
`summary_diffs` text,
|
|
`revert` text,
|
|
`permission` text,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
`time_compacting` integer,
|
|
`time_archived` integer,
|
|
CONSTRAINT `fk_session_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `todo` (
|
|
`session_id` text NOT NULL,
|
|
`content` text NOT NULL,
|
|
`status` text NOT NULL,
|
|
`priority` text NOT NULL,
|
|
`position` integer NOT NULL,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
CONSTRAINT `todo_pk` PRIMARY KEY(`session_id`, `position`),
|
|
CONSTRAINT `fk_todo_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `session_share` (
|
|
`session_id` text PRIMARY KEY,
|
|
`id` text NOT NULL,
|
|
`secret` text NOT NULL,
|
|
`url` text NOT NULL,
|
|
`time_created` integer NOT NULL,
|
|
`time_updated` integer NOT NULL,
|
|
CONSTRAINT `fk_session_share_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `message_session_idx` ON `message` (`session_id`);--> statement-breakpoint
|
|
CREATE INDEX `part_message_idx` ON `part` (`message_id`);--> statement-breakpoint
|
|
CREATE INDEX `part_session_idx` ON `part` (`session_id`);--> statement-breakpoint
|
|
CREATE INDEX `session_project_idx` ON `session` (`project_id`);--> statement-breakpoint
|
|
CREATE INDEX `session_parent_idx` ON `session` (`parent_id`);--> statement-breakpoint
|
|
CREATE INDEX `todo_session_idx` ON `todo` (`session_id`); |