jukebox-media-server 0.2.0 → 0.3.0

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,5 @@
1
+ CREATE TABLE `settings` (
2
+ `key` text PRIMARY KEY NOT NULL,
3
+ `value` text NOT NULL,
4
+ `updated_at` integer NOT NULL
5
+ );
@@ -0,0 +1,20 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE `__new_watch_progress` (
3
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
4
+ `profile_id` integer NOT NULL,
5
+ `movie_id` integer,
6
+ `episode_id` integer,
7
+ `current_time` integer NOT NULL,
8
+ `duration` integer,
9
+ `updated_at` integer NOT NULL,
10
+ FOREIGN KEY (`profile_id`) REFERENCES `profiles`(`id`) ON UPDATE no action ON DELETE cascade,
11
+ FOREIGN KEY (`movie_id`) REFERENCES `movies`(`id`) ON UPDATE no action ON DELETE cascade,
12
+ FOREIGN KEY (`episode_id`) REFERENCES `episodes`(`id`) ON UPDATE no action ON DELETE cascade
13
+ );
14
+ --> statement-breakpoint
15
+ INSERT INTO `__new_watch_progress`("id", "profile_id", "movie_id", "episode_id", "current_time", "duration", "updated_at") SELECT "id", "profile_id", "movie_id", "episode_id", "current_time", "duration", "updated_at" FROM `watch_progress`;--> statement-breakpoint
16
+ DROP TABLE `watch_progress`;--> statement-breakpoint
17
+ ALTER TABLE `__new_watch_progress` RENAME TO `watch_progress`;--> statement-breakpoint
18
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
19
+ CREATE UNIQUE INDEX `watch_progress_profile_movie_idx` ON `watch_progress` (`profile_id`,`movie_id`);--> statement-breakpoint
20
+ CREATE UNIQUE INDEX `watch_progress_profile_episode_idx` ON `watch_progress` (`profile_id`,`episode_id`);
@@ -0,0 +1,10 @@
1
+ CREATE TABLE `scan_jobs` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `started_at` integer NOT NULL,
4
+ `ended_at` integer,
5
+ `status` text NOT NULL,
6
+ `added` integer DEFAULT 0 NOT NULL,
7
+ `updated` integer DEFAULT 0 NOT NULL,
8
+ `total` integer DEFAULT 0 NOT NULL,
9
+ `error_message` text
10
+ );
@@ -0,0 +1,154 @@
1
+ -- Full-text search across movies, shows, and episodes via SQLite FTS5.
2
+ --
3
+ -- We use external-content virtual tables (content='<source>',
4
+ -- content_rowid='rowid') so the FTS tables don't duplicate the underlying
5
+ -- title/overview text. Triggers keep the FTS shadow tables in sync with the
6
+ -- real source tables on every INSERT, UPDATE, and DELETE.
7
+ --
8
+ -- Episodes also need to match against the parent show title, which FTS5 can't
9
+ -- JOIN on. Triggers on `episodes` resolve `shows.title` at write time and
10
+ -- store it in the episodes_fts virtual table as a third column.
11
+
12
+ CREATE VIRTUAL TABLE `movies_fts` USING fts5(
13
+ title,
14
+ overview,
15
+ genres,
16
+ content='movies',
17
+ content_rowid='rowid'
18
+ );
19
+ --> statement-breakpoint
20
+
21
+ CREATE VIRTUAL TABLE `shows_fts` USING fts5(
22
+ title,
23
+ overview,
24
+ genres,
25
+ content='shows',
26
+ content_rowid='rowid'
27
+ );
28
+ --> statement-breakpoint
29
+
30
+ CREATE VIRTUAL TABLE `episodes_fts` USING fts5(
31
+ title,
32
+ overview,
33
+ show_title,
34
+ content='episodes',
35
+ content_rowid='rowid'
36
+ );
37
+ --> statement-breakpoint
38
+
39
+ CREATE TRIGGER `movies_fts_insert` AFTER INSERT ON `movies` BEGIN
40
+ INSERT INTO `movies_fts`(rowid, title, overview, genres)
41
+ VALUES (NEW.rowid, NEW.title, NEW.overview, NEW.genres);
42
+ END;
43
+ --> statement-breakpoint
44
+
45
+ CREATE TRIGGER `movies_fts_delete` AFTER DELETE ON `movies` BEGIN
46
+ INSERT INTO `movies_fts`(`movies_fts`, rowid, title, overview, genres)
47
+ VALUES ('delete', OLD.rowid, OLD.title, OLD.overview, OLD.genres);
48
+ END;
49
+ --> statement-breakpoint
50
+
51
+ CREATE TRIGGER `movies_fts_update` AFTER UPDATE ON `movies` BEGIN
52
+ INSERT INTO `movies_fts`(`movies_fts`, rowid, title, overview, genres)
53
+ VALUES ('delete', OLD.rowid, OLD.title, OLD.overview, OLD.genres);
54
+ INSERT INTO `movies_fts`(rowid, title, overview, genres)
55
+ VALUES (NEW.rowid, NEW.title, NEW.overview, NEW.genres);
56
+ END;
57
+ --> statement-breakpoint
58
+
59
+ CREATE TRIGGER `shows_fts_insert` AFTER INSERT ON `shows` BEGIN
60
+ INSERT INTO `shows_fts`(rowid, title, overview, genres)
61
+ VALUES (NEW.rowid, NEW.title, NEW.overview, NEW.genres);
62
+ END;
63
+ --> statement-breakpoint
64
+
65
+ CREATE TRIGGER `shows_fts_delete` AFTER DELETE ON `shows` BEGIN
66
+ INSERT INTO `shows_fts`(`shows_fts`, rowid, title, overview, genres)
67
+ VALUES ('delete', OLD.rowid, OLD.title, OLD.overview, OLD.genres);
68
+ END;
69
+ --> statement-breakpoint
70
+
71
+ CREATE TRIGGER `shows_fts_update` AFTER UPDATE ON `shows` BEGIN
72
+ INSERT INTO `shows_fts`(`shows_fts`, rowid, title, overview, genres)
73
+ VALUES ('delete', OLD.rowid, OLD.title, OLD.overview, OLD.genres);
74
+ INSERT INTO `shows_fts`(rowid, title, overview, genres)
75
+ VALUES (NEW.rowid, NEW.title, NEW.overview, NEW.genres);
76
+ END;
77
+ --> statement-breakpoint
78
+
79
+ CREATE TRIGGER `episodes_fts_insert` AFTER INSERT ON `episodes` BEGIN
80
+ INSERT INTO `episodes_fts`(rowid, title, overview, show_title)
81
+ VALUES (
82
+ NEW.rowid,
83
+ NEW.title,
84
+ NEW.overview,
85
+ (SELECT `title` FROM `shows` WHERE `id` = NEW.show_id)
86
+ );
87
+ END;
88
+ --> statement-breakpoint
89
+
90
+ CREATE TRIGGER `episodes_fts_delete` AFTER DELETE ON `episodes` BEGIN
91
+ INSERT INTO `episodes_fts`(`episodes_fts`, rowid, title, overview, show_title)
92
+ VALUES (
93
+ 'delete',
94
+ OLD.rowid,
95
+ OLD.title,
96
+ OLD.overview,
97
+ (SELECT `title` FROM `shows` WHERE `id` = OLD.show_id)
98
+ );
99
+ END;
100
+ --> statement-breakpoint
101
+
102
+ CREATE TRIGGER `episodes_fts_update` AFTER UPDATE ON `episodes` BEGIN
103
+ INSERT INTO `episodes_fts`(`episodes_fts`, rowid, title, overview, show_title)
104
+ VALUES (
105
+ 'delete',
106
+ OLD.rowid,
107
+ OLD.title,
108
+ OLD.overview,
109
+ (SELECT `title` FROM `shows` WHERE `id` = OLD.show_id)
110
+ );
111
+ INSERT INTO `episodes_fts`(rowid, title, overview, show_title)
112
+ VALUES (
113
+ NEW.rowid,
114
+ NEW.title,
115
+ NEW.overview,
116
+ (SELECT `title` FROM `shows` WHERE `id` = NEW.show_id)
117
+ );
118
+ END;
119
+ --> statement-breakpoint
120
+
121
+ -- When a show's title changes, refresh the show_title column on every
122
+ -- matching episode_fts row. We can't use 'rebuild' here because
123
+ -- episodes_fts is external-content backed by `episodes`, which doesn't
124
+ -- know about the show title — so we issue a manual delete/insert per
125
+ -- affected episode rowid.
126
+ CREATE TRIGGER `episodes_fts_show_title_update` AFTER UPDATE OF `title` ON `shows` BEGIN
127
+ INSERT INTO `episodes_fts`(`episodes_fts`, rowid, title, overview, show_title)
128
+ SELECT 'delete', `episodes`.rowid, `episodes`.`title`, `episodes`.`overview`, OLD.`title`
129
+ FROM `episodes`
130
+ WHERE `episodes`.`show_id` = NEW.`id`;
131
+ INSERT INTO `episodes_fts`(rowid, title, overview, show_title)
132
+ SELECT `episodes`.rowid, `episodes`.`title`, `episodes`.`overview`, NEW.`title`
133
+ FROM `episodes`
134
+ WHERE `episodes`.`show_id` = NEW.`id`;
135
+ END;
136
+ --> statement-breakpoint
137
+
138
+ -- One-time backfill for any rows that already exist before this migration ran.
139
+ INSERT INTO `movies_fts`(rowid, title, overview, genres)
140
+ SELECT rowid, title, overview, genres FROM `movies`;
141
+ --> statement-breakpoint
142
+
143
+ INSERT INTO `shows_fts`(rowid, title, overview, genres)
144
+ SELECT rowid, title, overview, genres FROM `shows`;
145
+ --> statement-breakpoint
146
+
147
+ INSERT INTO `episodes_fts`(rowid, title, overview, show_title)
148
+ SELECT
149
+ `episodes`.rowid,
150
+ `episodes`.`title`,
151
+ `episodes`.`overview`,
152
+ `shows`.`title`
153
+ FROM `episodes`
154
+ LEFT JOIN `shows` ON `shows`.`id` = `episodes`.`show_id`;
@@ -0,0 +1,10 @@
1
+ CREATE TABLE `subtitles` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `movie_id` integer,
4
+ `episode_id` integer,
5
+ `file_path` text NOT NULL,
6
+ `language` text NOT NULL,
7
+ `format` text NOT NULL,
8
+ FOREIGN KEY (`movie_id`) REFERENCES `movies`(`id`) ON UPDATE no action ON DELETE cascade,
9
+ FOREIGN KEY (`episode_id`) REFERENCES `episodes`(`id`) ON UPDATE no action ON DELETE cascade
10
+ );