CREATE TABLE `attachments` ( `id` text PRIMARY KEY NOT NULL, `note_id` text NOT NULL, `filename` text NOT NULL, `mime_type` text NOT NULL, `size` integer NOT NULL, `path` text NOT NULL, `thumbnail_path` text, `created_at` integer NOT NULL, FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `note_tags` ( `note_id` text NOT NULL, `tag_id` integer NOT NULL, FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE INDEX `note_tags_note_id_idx` ON `note_tags` (`note_id`);--> statement-breakpoint CREATE INDEX `note_tags_tag_id_idx` ON `note_tags` (`tag_id`);--> statement-breakpoint CREATE TABLE `notes` ( `id` text PRIMARY KEY NOT NULL, `title` text DEFAULT '' NOT NULL, `content` text DEFAULT '' NOT NULL, `color` text DEFAULT 'default' NOT NULL, `pinned` integer DEFAULT false NOT NULL, `archived` integer DEFAULT false NOT NULL, `trashed` integer DEFAULT false NOT NULL, `trashed_at` integer, `checklist_mode` integer DEFAULT false NOT NULL, `sort_order` integer DEFAULT 0 NOT NULL, `created_at` integer NOT NULL, `updated_at` integer NOT NULL, `version` integer DEFAULT 1 NOT NULL ); --> statement-breakpoint CREATE INDEX `notes_trashed_archived_idx` ON `notes` (`trashed`,`archived`);--> statement-breakpoint CREATE INDEX `notes_updated_at_idx` ON `notes` (`updated_at`);--> statement-breakpoint CREATE TABLE `sessions` ( `id` text PRIMARY KEY NOT NULL, `user_id` integer NOT NULL, `expires_at` integer NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `sync_log` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `note_id` text NOT NULL, `operation` text NOT NULL, `timestamp` integer NOT NULL, `client_id` text NOT NULL, FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE INDEX `sync_log_timestamp_idx` ON `sync_log` (`timestamp`);--> statement-breakpoint CREATE TABLE `tags` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` text NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `tags_name_unique` ON `tags` (`name`);--> statement-breakpoint CREATE TABLE `users` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `password_hash` text NOT NULL, `created_at` integer NOT NULL );