jukebox-media-server 0.3.0 → 0.5.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.
- package/README.md +2 -2
- package/dist/client/assets/{Watch-DNFM488K.js → Watch-Ja4PAA8Y.js} +32 -32
- package/dist/client/assets/index-AENKhh_8.css +1 -0
- package/dist/client/assets/index-Cm9WIhoR.js +58 -0
- package/dist/client/index.html +2 -2
- package/dist/client/sw.js +1 -1
- package/dist/server/better-sqlite3-Dy_YhTFe.js +2709 -0
- package/dist/server/index.js +455 -4547
- package/dist/server/indexes-VMR6QVVl.js +1409 -0
- package/dist/server/migrator-CWPnMvx5.js +37 -0
- package/drizzle/0010_metadata_rename.sql +49 -0
- package/drizzle/meta/0009_snapshot.json +1 -1
- package/drizzle/meta/0010_snapshot.json +1059 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +2 -1
- package/dist/client/assets/index-BYBYJ0kS.css +0 -1
- package/dist/client/assets/index-COFfIwFC.js +0 -58
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
//#region node_modules/drizzle-orm/migrator.js
|
|
4
|
+
function readMigrationFiles(config) {
|
|
5
|
+
const migrationFolderTo = config.migrationsFolder;
|
|
6
|
+
const migrationQueries = [];
|
|
7
|
+
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
|
|
8
|
+
if (!fs.existsSync(journalPath)) throw new Error(`Can't find meta/_journal.json file`);
|
|
9
|
+
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
|
|
10
|
+
const journal = JSON.parse(journalAsString);
|
|
11
|
+
for (const journalEntry of journal.entries) {
|
|
12
|
+
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
|
|
13
|
+
try {
|
|
14
|
+
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
|
|
15
|
+
const result = query.split("--> statement-breakpoint").map((it) => {
|
|
16
|
+
return it;
|
|
17
|
+
});
|
|
18
|
+
migrationQueries.push({
|
|
19
|
+
sql: result,
|
|
20
|
+
bps: journalEntry.breakpoints,
|
|
21
|
+
folderMillis: journalEntry.when,
|
|
22
|
+
hash: crypto.createHash("sha256").update(query).digest("hex")
|
|
23
|
+
});
|
|
24
|
+
} catch {
|
|
25
|
+
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return migrationQueries;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region node_modules/drizzle-orm/better-sqlite3/migrator.js
|
|
32
|
+
function migrate(db, config) {
|
|
33
|
+
const migrations = readMigrationFiles(config);
|
|
34
|
+
db.dialect.migrate(migrations, db.session, config);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { migrate };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
-- Migration: rename TMDB-specific columns to neutral "external_id" +
|
|
2
|
+
-- "poster_url"/"backdrop_url"/"still_url" so the project can talk to any
|
|
3
|
+
-- metadata API. Also drop the tmdbApiKey setting row since we no longer
|
|
4
|
+
-- store a key.
|
|
5
|
+
--
|
|
6
|
+
-- The stored poster/backdrop/still values used to be relative TMDB paths
|
|
7
|
+
-- (e.g. "/abc.jpg") and the frontend prefixed image.tmdb.org. The new API
|
|
8
|
+
-- returns absolute URLs, so we null out the old values — a re-scan will
|
|
9
|
+
-- repopulate them with fully-qualified URLs.
|
|
10
|
+
--
|
|
11
|
+
-- SQLite 3.35+ supports RENAME COLUMN and DROP COLUMN, which better-sqlite3
|
|
12
|
+
-- ships with, so we can do this in-place without table recreation.
|
|
13
|
+
|
|
14
|
+
-- movies ---------------------------------------------------------------
|
|
15
|
+
ALTER TABLE `movies` ADD COLUMN `external_id` text;--> statement-breakpoint
|
|
16
|
+
UPDATE `movies` SET `external_id` = CAST(`tmdb_id` AS TEXT) WHERE `tmdb_id` IS NOT NULL;--> statement-breakpoint
|
|
17
|
+
ALTER TABLE `movies` DROP COLUMN `tmdb_id`;--> statement-breakpoint
|
|
18
|
+
|
|
19
|
+
ALTER TABLE `movies` RENAME COLUMN `poster_path` TO `poster_url`;--> statement-breakpoint
|
|
20
|
+
ALTER TABLE `movies` RENAME COLUMN `backdrop_path` TO `backdrop_url`;--> statement-breakpoint
|
|
21
|
+
|
|
22
|
+
UPDATE `movies` SET `poster_url` = NULL WHERE `poster_url` IS NOT NULL;--> statement-breakpoint
|
|
23
|
+
UPDATE `movies` SET `backdrop_url` = NULL WHERE `backdrop_url` IS NOT NULL;--> statement-breakpoint
|
|
24
|
+
|
|
25
|
+
-- shows ----------------------------------------------------------------
|
|
26
|
+
ALTER TABLE `shows` ADD COLUMN `external_id` text;--> statement-breakpoint
|
|
27
|
+
UPDATE `shows` SET `external_id` = CAST(`tmdb_id` AS TEXT) WHERE `tmdb_id` IS NOT NULL;--> statement-breakpoint
|
|
28
|
+
ALTER TABLE `shows` DROP COLUMN `tmdb_id`;--> statement-breakpoint
|
|
29
|
+
|
|
30
|
+
ALTER TABLE `shows` RENAME COLUMN `poster_path` TO `poster_url`;--> statement-breakpoint
|
|
31
|
+
ALTER TABLE `shows` RENAME COLUMN `backdrop_path` TO `backdrop_url`;--> statement-breakpoint
|
|
32
|
+
|
|
33
|
+
UPDATE `shows` SET `poster_url` = NULL WHERE `poster_url` IS NOT NULL;--> statement-breakpoint
|
|
34
|
+
UPDATE `shows` SET `backdrop_url` = NULL WHERE `backdrop_url` IS NOT NULL;--> statement-breakpoint
|
|
35
|
+
|
|
36
|
+
-- seasons --------------------------------------------------------------
|
|
37
|
+
ALTER TABLE `seasons` RENAME COLUMN `poster_path` TO `poster_url`;--> statement-breakpoint
|
|
38
|
+
UPDATE `seasons` SET `poster_url` = NULL WHERE `poster_url` IS NOT NULL;--> statement-breakpoint
|
|
39
|
+
|
|
40
|
+
-- episodes -------------------------------------------------------------
|
|
41
|
+
-- episodes.tmdb_id was never populated (always null), so no copy needed.
|
|
42
|
+
ALTER TABLE `episodes` ADD COLUMN `external_id` text;--> statement-breakpoint
|
|
43
|
+
ALTER TABLE `episodes` DROP COLUMN `tmdb_id`;--> statement-breakpoint
|
|
44
|
+
|
|
45
|
+
ALTER TABLE `episodes` RENAME COLUMN `still_path` TO `still_url`;--> statement-breakpoint
|
|
46
|
+
UPDATE `episodes` SET `still_url` = NULL WHERE `still_url` IS NOT NULL;--> statement-breakpoint
|
|
47
|
+
|
|
48
|
+
-- settings: drop the unused TMDB API key row ---------------------------
|
|
49
|
+
DELETE FROM `settings` WHERE `key` = 'tmdbApiKey';
|