@okhay-p/mivra 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,66 @@
1
+ CREATE TABLE `note_chunks` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `note_id` text NOT NULL,
4
+ `seq` integer NOT NULL,
5
+ `heading` text,
6
+ `text` text NOT NULL,
7
+ FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON UPDATE no action ON DELETE cascade
8
+ );
9
+ --> statement-breakpoint
10
+ CREATE UNIQUE INDEX `note_chunks_note_seq_idx` ON `note_chunks` (`note_id`,`seq`);--> statement-breakpoint
11
+ CREATE TABLE `note_links` (
12
+ `note_id` text NOT NULL,
13
+ `target` text NOT NULL,
14
+ `kind` text NOT NULL,
15
+ PRIMARY KEY(`note_id`, `target`, `kind`),
16
+ FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON UPDATE no action ON DELETE cascade
17
+ );
18
+ --> statement-breakpoint
19
+ CREATE TABLE `note_tags` (
20
+ `note_id` text NOT NULL,
21
+ `tag` text NOT NULL,
22
+ PRIMARY KEY(`note_id`, `tag`),
23
+ FOREIGN KEY (`note_id`) REFERENCES `notes`(`id`) ON UPDATE no action ON DELETE cascade
24
+ );
25
+ --> statement-breakpoint
26
+ CREATE INDEX `note_tags_tag_idx` ON `note_tags` (`tag`);--> statement-breakpoint
27
+ CREATE TABLE `notes` (
28
+ `id` text PRIMARY KEY NOT NULL,
29
+ `import_id` text NOT NULL,
30
+ `path` text NOT NULL,
31
+ `title` text NOT NULL,
32
+ `title_key` text NOT NULL,
33
+ `aliases` text NOT NULL,
34
+ `body` text NOT NULL,
35
+ `hash` text NOT NULL,
36
+ `created_at` integer NOT NULL,
37
+ `updated_at` integer NOT NULL,
38
+ FOREIGN KEY (`import_id`) REFERENCES `vault_imports`(`id`) ON UPDATE no action ON DELETE cascade
39
+ );
40
+ --> statement-breakpoint
41
+ CREATE UNIQUE INDEX `notes_import_path_idx` ON `notes` (`import_id`,`path`);--> statement-breakpoint
42
+ CREATE INDEX `notes_import_title_idx` ON `notes` (`import_id`,`title_key`);--> statement-breakpoint
43
+ CREATE TABLE `vault_imports` (
44
+ `id` text PRIMARY KEY NOT NULL,
45
+ `name` text NOT NULL,
46
+ `source` text NOT NULL,
47
+ `created_at` integer NOT NULL,
48
+ `updated_at` integer NOT NULL
49
+ );
50
+ --> statement-breakpoint
51
+ CREATE UNIQUE INDEX `vault_imports_name_idx` ON `vault_imports` (`name`);--> statement-breakpoint
52
+ -- Hand-written: Drizzle doesn't model FTS5. An external-content index over note_chunks, kept in sync by triggers, which also fire on foreign-key cascades.
53
+ CREATE VIRTUAL TABLE `note_chunks_fts` USING fts5(`heading`, `text`, content=`note_chunks`, content_rowid=`id`, tokenize='porter unicode61 remove_diacritics 2');
54
+ --> statement-breakpoint
55
+ CREATE TRIGGER `note_chunks_fts_insert` AFTER INSERT ON `note_chunks` BEGIN
56
+ INSERT INTO `note_chunks_fts`(rowid, `heading`, `text`) VALUES (new.`id`, new.`heading`, new.`text`);
57
+ END;
58
+ --> statement-breakpoint
59
+ CREATE TRIGGER `note_chunks_fts_delete` AFTER DELETE ON `note_chunks` BEGIN
60
+ INSERT INTO `note_chunks_fts`(`note_chunks_fts`, rowid, `heading`, `text`) VALUES ('delete', old.`id`, old.`heading`, old.`text`);
61
+ END;
62
+ --> statement-breakpoint
63
+ CREATE TRIGGER `note_chunks_fts_update` AFTER UPDATE ON `note_chunks` BEGIN
64
+ INSERT INTO `note_chunks_fts`(`note_chunks_fts`, rowid, `heading`, `text`) VALUES ('delete', old.`id`, old.`heading`, old.`text`);
65
+ INSERT INTO `note_chunks_fts`(rowid, `heading`, `text`) VALUES (new.`id`, new.`heading`, new.`text`);
66
+ END;