CREATE TABLE `alert` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `kind` text NOT NULL, `subject_type` text NOT NULL, `subject_id` integer DEFAULT 0 NOT NULL, `period` text DEFAULT '' NOT NULL, `area` text DEFAULT 'money' NOT NULL, `severity` text DEFAULT 'info' NOT NULL, `title` text NOT NULL, `body` text, `link` text, `rank` integer DEFAULT 0 NOT NULL, `created_at` text NOT NULL, `updated_at` text NOT NULL, `read_at` text, `dismissed_at` text, `resolved_at` text ); --> statement-breakpoint CREATE UNIQUE INDEX `alert_unique` ON `alert` (`kind`,`subject_type`,`subject_id`,`period`);--> statement-breakpoint CREATE INDEX `alert_open_idx` ON `alert` (`resolved_at`,`dismissed_at`);--> statement-breakpoint CREATE TABLE `budget` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `category_id` integer NOT NULL, `year` integer NOT NULL, `month` integer DEFAULT 0 NOT NULL, `amount_cents` integer NOT NULL, `updated_at` text NOT NULL, FOREIGN KEY (`category_id`) REFERENCES `category`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `budget_unique` ON `budget` (`category_id`,`year`,`month`);--> statement-breakpoint CREATE INDEX `budget_year_idx` ON `budget` (`year`);--> statement-breakpoint CREATE TABLE `subscription` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` text NOT NULL, `kind` text DEFAULT 'subscription' NOT NULL, `merchant` text NOT NULL, `aliases` text DEFAULT '[]' NOT NULL, `catalog_key` text, `cadence` text DEFAULT 'monthly' NOT NULL, `expected_cents` integer NOT NULL, `account_id` integer, `category_id` integer, `status` text DEFAULT 'suggested' NOT NULL, `confidence` text DEFAULT 'likely' NOT NULL, `source` text DEFAULT 'detected' NOT NULL, `trial_ends_on` text, `cancelled_on` text, `first_charge_on` text, `last_charge_on` text, `next_expected_on` text, `manage_url` text, `note` text, `alerts_on` integer DEFAULT true NOT NULL, `created_at` text NOT NULL, `updated_at` text NOT NULL, FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON UPDATE no action ON DELETE set null, FOREIGN KEY (`category_id`) REFERENCES `category`(`id`) ON UPDATE no action ON DELETE set null ); --> statement-breakpoint CREATE INDEX `subscription_merchant_idx` ON `subscription` (`merchant`);--> statement-breakpoint CREATE INDEX `subscription_status_idx` ON `subscription` (`status`);--> statement-breakpoint ALTER TABLE `txn` ADD `subscription_id` integer;--> statement-breakpoint CREATE INDEX `txn_subscription_idx` ON `txn` (`subscription_id`);