CREATE TABLE `tasks` (
	`id` text NOT NULL,
	`user_id` text NOT NULL,
	`title` text NOT NULL,
	`context_id` text NOT NULL,
	`history_entry_id` text,
	`assignee` text,
	`status` text DEFAULT 'open' NOT NULL,
	`completed_at` text,
	`due_date` text,
	`source` text DEFAULT 'local' NOT NULL,
	`external_id` text,
	`external_url` text,
	`updated_at` text NOT NULL,
	`deleted_at` text,
	`purged_at` text,
	`version` integer DEFAULT 1 NOT NULL,
	PRIMARY KEY(`id`, `user_id`)
);
--> statement-breakpoint
CREATE INDEX `tasks_updated_at_idx` ON `tasks` (`updated_at`);--> statement-breakpoint
CREATE INDEX `tasks_context_id_idx` ON `tasks` (`context_id`);--> statement-breakpoint
CREATE INDEX `tasks_assignee_idx` ON `tasks` (`assignee`);--> statement-breakpoint
CREATE INDEX `tasks_user_id_idx` ON `tasks` (`user_id`);--> statement-breakpoint
CREATE INDEX `tasks_source_external_id_idx` ON `tasks` (`user_id`,`source`,`external_id`);