CREATE TABLE `editorial_comments` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `item_id` integer NOT NULL, `user_id` integer, `body` text NOT NULL, `created_at` integer DEFAULT (unixepoch()) NOT NULL, FOREIGN KEY (`item_id`) REFERENCES `editorial_items`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null ); --> statement-breakpoint CREATE INDEX `editorial_comments_item_idx` ON `editorial_comments` (`item_id`);--> statement-breakpoint CREATE TABLE `editorial_items` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `title` text NOT NULL, `notes` text DEFAULT '' NOT NULL, `kind` text DEFAULT 'post' NOT NULL, `status` text DEFAULT 'idea' NOT NULL, `assignee_id` integer, `date` text DEFAULT '' NOT NULL, `due_date` text DEFAULT '' NOT NULL, `post_id` integer, `page_id` integer, `created_by` integer, `created_at` integer DEFAULT (unixepoch()) NOT NULL, `updated_at` integer DEFAULT (unixepoch()) NOT NULL, FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`post_id`) REFERENCES `posts`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`page_id`) REFERENCES `pages`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`created_by`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null ); --> statement-breakpoint CREATE INDEX `editorial_date_idx` ON `editorial_items` (`date`);--> statement-breakpoint CREATE INDEX `editorial_assignee_idx` ON `editorial_items` (`assignee_id`);