mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-10 20:02:37 +02:00
refactor(modules): master/drop/migrations schema layout + harden install
Mirror core's DB layout at the module level: one master database.sql (full current schema), one database_drop.sql (teardown), and forward-only migrations/<semver>.sql deltas. ModuleMigrator gains install()/uninstall(); up() reads migrations/*.sql; down() removed. - watch: database.sql (delete_missing folded into watch_folders), database_drop.sql, migrations/1.0.1.sql; drop 1.0.0.up/down.sql; getVersion() -> 1.0.1 (matches module.json). - Move core migration 004_add_watch_delete_missing.sql into the watch module. - installModule no longer wraps the DDL migration in a transaction: MySQL/MariaDB implicitly commit DDL, so the wrapping rollback() only masked the real SQL error. - syncBundledModules retries a previously-failed install (skips only admin-disabled) so `console.php status` self-heals.
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
-- watch module — master schema (current version)
|
||||
-- Full CREATE + seed for a fresh install. Must always reflect the LATEST schema
|
||||
-- (every migrations/<semver>.sql delta folded in), mirroring core's
|
||||
-- bin/install/database.sql. Owns: watch_categories, watch_folders, watch_logs,
|
||||
-- watch_refresh. plex depends on watch and reuses watch_categories + watch_folders.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `watch_categories` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`type` int(1) DEFAULT '0',
|
||||
`genre_id` int(8) DEFAULT '0',
|
||||
`genre` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`category_id` int(8) DEFAULT '0',
|
||||
`bouquets` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `watch_folders` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`type` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`directory` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`rclone_dir` varchar(2048) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`server_id` int(8) DEFAULT '0',
|
||||
`category_id` int(8) DEFAULT '0',
|
||||
`bouquets` varchar(4096) COLLATE utf8_unicode_ci DEFAULT '[]',
|
||||
`last_run` int(32) DEFAULT '0',
|
||||
`active` int(1) DEFAULT '1',
|
||||
`delete_missing` tinyint(1) DEFAULT '0',
|
||||
`disable_tmdb` int(1) DEFAULT '0',
|
||||
`ignore_no_match` int(1) DEFAULT '0',
|
||||
`auto_subtitles` int(1) DEFAULT '0',
|
||||
`fb_bouquets` varchar(4096) COLLATE utf8_unicode_ci DEFAULT '[]',
|
||||
`fb_category_id` int(8) DEFAULT '0',
|
||||
`allowed_extensions` varchar(4096) COLLATE utf8_unicode_ci DEFAULT '[]',
|
||||
`language` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`read_native` tinyint(4) DEFAULT '0',
|
||||
`movie_symlink` tinyint(4) DEFAULT '0',
|
||||
`auto_encode` tinyint(4) DEFAULT '1',
|
||||
`ffprobe_input` tinyint(4) DEFAULT '1',
|
||||
`transcode_profile_id` int(11) DEFAULT '0',
|
||||
`auto_upgrade` tinyint(4) DEFAULT '0',
|
||||
`fallback_title` tinyint(4) DEFAULT '0',
|
||||
`plex_ip` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`plex_port` int(5) DEFAULT '0',
|
||||
`plex_username` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`plex_password` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`plex_libraries` mediumtext COLLATE utf8_unicode_ci,
|
||||
`scan_missing` tinyint(4) DEFAULT '0',
|
||||
`extract_metadata` tinyint(4) DEFAULT '0',
|
||||
`store_categories` tinyint(1) DEFAULT '0',
|
||||
`duplicate_tmdb` tinyint(1) DEFAULT '0',
|
||||
`check_tmdb` tinyint(1) DEFAULT '1',
|
||||
`remove_subtitles` tinyint(1) DEFAULT '0',
|
||||
`target_container` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`server_add` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`direct_proxy` tinyint(1) DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `watch_logs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`type` int(1) DEFAULT '0',
|
||||
`server_id` int(8) DEFAULT '0',
|
||||
`filename` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`status` int(1) DEFAULT '0',
|
||||
`stream_id` int(8) DEFAULT '0',
|
||||
`dateadded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `watch_refresh` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`type` int(1) DEFAULT '0',
|
||||
`stream_id` int(16) DEFAULT '0',
|
||||
`status` int(8) DEFAULT '0',
|
||||
`dateadded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- Default TMDb genre categories (idempotent — skipped if already present).
|
||||
INSERT IGNORE INTO `watch_categories` (`id`, `type`, `genre_id`, `genre`, `category_id`, `bouquets`) VALUES
|
||||
(1, 1, 28, 'Action', 0, '[]'),
|
||||
(2, 1, 12, 'Adventure', 0, '[]'),
|
||||
(3, 1, 16, 'Animation', 0, '[]'),
|
||||
(4, 1, 35, 'Comedy', 0, '[]'),
|
||||
(5, 1, 80, 'Crime', 0, '[]'),
|
||||
(6, 1, 99, 'Documentary', 0, '[]'),
|
||||
(7, 1, 18, 'Drama', 0, '[]'),
|
||||
(8, 1, 10751, 'Family', 0, '[]'),
|
||||
(9, 1, 14, 'Fantasy', 0, '[]'),
|
||||
(10, 1, 36, 'History', 0, '[]'),
|
||||
(11, 1, 27, 'Horror', 0, '[]'),
|
||||
(12, 1, 10402, 'Music', 0, '[]'),
|
||||
(13, 1, 9648, 'Mystery', 0, '[]'),
|
||||
(14, 1, 10749, 'Romance', 0, '[]'),
|
||||
(15, 1, 878, 'Science Fiction', 0, '[]'),
|
||||
(16, 1, 10770, 'TV Movie', 0, '[]'),
|
||||
(17, 1, 53, 'Thriller', 0, '[]'),
|
||||
(18, 1, 10752, 'War', 0, '[]'),
|
||||
(19, 1, 37, 'Western', 0, '[]'),
|
||||
(20, 2, 28, 'Action', 0, '[]'),
|
||||
(21, 2, 12, 'Adventure', 0, '[]'),
|
||||
(22, 2, 16, 'Animation', 0, '[]'),
|
||||
(23, 2, 35, 'Comedy', 0, '[]'),
|
||||
(24, 2, 80, 'Crime', 0, '[]'),
|
||||
(25, 2, 99, 'Documentary', 0, '[]'),
|
||||
(26, 2, 18, 'Drama', 0, '[]'),
|
||||
(27, 2, 10751, 'Family', 0, '[]'),
|
||||
(28, 2, 14, 'Fantasy', 0, '[]'),
|
||||
(29, 2, 36, 'History', 0, '[]'),
|
||||
(30, 2, 27, 'Horror', 0, '[]'),
|
||||
(31, 2, 10402, 'Music', 0, '[]'),
|
||||
(32, 2, 9648, 'Mystery', 0, '[]'),
|
||||
(33, 2, 10749, 'Romance', 0, '[]'),
|
||||
(34, 2, 878, 'Science Fiction', 0, '[]'),
|
||||
(35, 2, 10770, 'TV Movie', 0, '[]'),
|
||||
(36, 2, 53, 'Thriller', 0, '[]'),
|
||||
(37, 2, 10752, 'War', 0, '[]'),
|
||||
(38, 2, 37, 'Western', 0, '[]'),
|
||||
(39, 1, 10759, 'Action & Adventure', 0, '[]'),
|
||||
(40, 2, 10759, 'Action & Adventure', 0, '[]'),
|
||||
(47, 1, 10762, 'Kids', 0, '[]'),
|
||||
(48, 2, 10762, 'Kids', 0, '[]'),
|
||||
(50, 1, 10763, 'News', 0, '[]'),
|
||||
(51, 2, 10763, 'News', 0, '[]'),
|
||||
(52, 1, 10764, 'Reality', 0, '[]'),
|
||||
(53, 2, 10764, 'Reality', 0, '[]'),
|
||||
(54, 1, 10765, 'Sci-Fi & Fantasy', 0, '[]'),
|
||||
(55, 2, 10765, 'Sci-Fi & Fantasy', 0, '[]'),
|
||||
(56, 1, 10766, 'Soap', 0, '[]'),
|
||||
(57, 2, 10766, 'Soap', 0, '[]'),
|
||||
(58, 1, 10767, 'Talk', 0, '[]'),
|
||||
(59, 2, 10767, 'Talk', 0, '[]'),
|
||||
(60, 1, 10768, 'War & Politics', 0, '[]'),
|
||||
(61, 2, 10768, 'War & Politics', 0, '[]'),
|
||||
(62, 3, 1, 'Action', 0, '[]'),
|
||||
(63, 3, 2, 'Action / Adventure', 0, '[]'),
|
||||
(64, 3, 3, 'Adventure', 0, '[]'),
|
||||
(65, 3, 4, 'Animation', 0, '[]'),
|
||||
(66, 3, 5, 'Anime', 0, '[]'),
|
||||
(67, 3, 6, 'Biography', 0, '[]'),
|
||||
(68, 3, 7, 'Children', 0, '[]'),
|
||||
(69, 3, 8, 'Comedy', 0, '[]'),
|
||||
(70, 3, 9, 'Crime', 0, '[]'),
|
||||
(71, 3, 10, 'Documentary', 0, '[]'),
|
||||
(72, 3, 11, 'Drama', 0, '[]'),
|
||||
(73, 3, 12, 'Family', 0, '[]'),
|
||||
(74, 3, 13, 'Fantasy', 0, '[]'),
|
||||
(75, 3, 14, 'History', 0, '[]'),
|
||||
(76, 3, 15, 'Horror', 0, '[]'),
|
||||
(77, 3, 16, 'Martial Arts', 0, '[]'),
|
||||
(78, 3, 17, 'Music', 0, '[]'),
|
||||
(79, 3, 18, 'Musical', 0, '[]'),
|
||||
(80, 3, 19, 'Mystery', 0, '[]'),
|
||||
(81, 3, 20, 'News', 0, '[]'),
|
||||
(82, 3, 21, 'Non-Fiction', 0, '[]'),
|
||||
(83, 3, 22, 'Reality', 0, '[]'),
|
||||
(84, 3, 23, 'Romance', 0, '[]'),
|
||||
(85, 3, 24, 'Science Fiction', 0, '[]'),
|
||||
(86, 3, 25, 'Short', 0, '[]'),
|
||||
(87, 3, 26, 'Sport', 0, '[]'),
|
||||
(88, 3, 27, 'Talk Show', 0, '[]'),
|
||||
(89, 3, 28, 'Thriller', 0, '[]'),
|
||||
(90, 3, 29, 'TV Movie', 0, '[]'),
|
||||
(91, 3, 30, 'War', 0, '[]'),
|
||||
(92, 3, 31, 'Western', 0, '[]'),
|
||||
(93, 4, 1, 'Action', 0, '[]'),
|
||||
(94, 4, 2, 'Action & Adventure', 0, '[]'),
|
||||
(95, 4, 3, 'Adventure', 0, '[]'),
|
||||
(96, 4, 4, 'Animation', 0, '[]'),
|
||||
(97, 4, 5, 'Anime', 0, '[]'),
|
||||
(98, 4, 6, 'Biography', 0, '[]'),
|
||||
(99, 4, 7, 'Children', 0, '[]'),
|
||||
(100, 4, 8, 'Comedy', 0, '[]'),
|
||||
(101, 4, 9, 'Crime', 0, '[]'),
|
||||
(102, 4, 10, 'Documentary', 0, '[]'),
|
||||
(103, 4, 11, 'Drama', 0, '[]'),
|
||||
(104, 4, 12, 'Family', 0, '[]'),
|
||||
(105, 4, 13, 'Fantasy', 0, '[]'),
|
||||
(106, 4, 14, 'Food', 0, '[]'),
|
||||
(107, 4, 15, 'Game Show', 0, '[]'),
|
||||
(108, 4, 16, 'History', 0, '[]'),
|
||||
(109, 4, 17, 'Home and Garden', 0, '[]'),
|
||||
(110, 4, 18, 'Horror', 0, '[]'),
|
||||
(111, 4, 19, 'Indie', 0, '[]'),
|
||||
(112, 4, 20, 'Martial Arts', 0, '[]'),
|
||||
(113, 4, 21, 'Mini-Series', 0, '[]'),
|
||||
(114, 4, 22, 'Musical', 0, '[]'),
|
||||
(115, 4, 23, 'Mystery', 0, '[]'),
|
||||
(116, 4, 24, 'News', 0, '[]'),
|
||||
(117, 4, 25, 'Reality', 0, '[]'),
|
||||
(118, 4, 26, 'Romance', 0, '[]'),
|
||||
(119, 4, 27, 'Science Fiction', 0, '[]'),
|
||||
(120, 4, 28, 'Sci-Fi & Fantasy', 0, '[]'),
|
||||
(121, 4, 29, 'Soap', 0, '[]'),
|
||||
(122, 4, 30, 'Special Interest', 0, '[]'),
|
||||
(123, 4, 31, 'Sport', 0, '[]'),
|
||||
(124, 4, 32, 'Suspense', 0, '[]'),
|
||||
(125, 4, 33, 'Talk', 0, '[]'),
|
||||
(126, 4, 34, 'Talk Show', 0, '[]'),
|
||||
(127, 4, 35, 'Thriller', 0, '[]'),
|
||||
(128, 4, 36, 'Thriller', 0, '[]'),
|
||||
(129, 4, 37, 'Travel', 0, '[]'),
|
||||
(130, 4, 38, 'War', 0, '[]'),
|
||||
(131, 4, 39, 'War & Politics', 0, '[]'),
|
||||
(132, 4, 40, 'Western', 0, '[]');
|
||||
Reference in New Issue
Block a user