CREATE TABLE `api_keys` (
	`id` text PRIMARY KEY NOT NULL,
	`name` text NOT NULL,
	`key` text NOT NULL,
	`last_used` integer,
	`created_at` integer
);
--> statement-breakpoint
CREATE UNIQUE INDEX `api_keys_key_unique` ON `api_keys` (`key`);--> statement-breakpoint
CREATE TABLE `email_config` (
	`id` text PRIMARY KEY NOT NULL,
	`inbox_email` text,
	`is_active` integer DEFAULT true,
	`created_at` integer
);
--> statement-breakpoint
CREATE UNIQUE INDEX `email_config_inbox_email_unique` ON `email_config` (`inbox_email`);--> statement-breakpoint
CREATE TABLE `folders` (
	`id` text PRIMARY KEY NOT NULL,
	`name` text NOT NULL,
	`color` text DEFAULT '#3b82f6',
	`icon` text DEFAULT 'folder',
	`parent_id` text,
	`sort_order` integer DEFAULT 0,
	`created_at` integer
);
--> statement-breakpoint
CREATE TABLE `highlights` (
	`id` text PRIMARY KEY NOT NULL,
	`article_id` text NOT NULL,
	`text` text NOT NULL,
	`note` text,
	`color` text DEFAULT '#fbbf24',
	`start_offset` integer,
	`end_offset` integer,
	`created_at` integer
);
--> statement-breakpoint
CREATE TABLE `reading_goals` (
	`id` text PRIMARY KEY NOT NULL,
	`type` text NOT NULL,
	`metric` text NOT NULL,
	`target` integer NOT NULL,
	`is_active` integer DEFAULT true,
	`created_at` integer
);
--> statement-breakpoint
CREATE TABLE `reading_stats` (
	`id` text PRIMARY KEY NOT NULL,
	`date` text NOT NULL,
	`articles_read` integer DEFAULT 0,
	`articles_added` integer DEFAULT 0,
	`words_read` integer DEFAULT 0,
	`time_spent_seconds` integer DEFAULT 0,
	`streak` integer DEFAULT 0
);
--> statement-breakpoint
CREATE UNIQUE INDEX `reading_stats_date_unique` ON `reading_stats` (`date`);--> statement-breakpoint
CREATE TABLE `settings` (
	`key` text PRIMARY KEY NOT NULL,
	`value` text NOT NULL,
	`updated_at` integer
);
--> statement-breakpoint
ALTER TABLE `articles` ADD `reading_time_seconds` integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE `articles` ADD `folder_id` text;--> statement-breakpoint
ALTER TABLE `articles` ADD `finished_at` integer;