mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-25 03:03:12 +01: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:
@@ -60,7 +60,7 @@ class WatchModule extends BaseModule {
|
||||
}
|
||||
|
||||
public function getVersion(): string {
|
||||
return '1.0.0';
|
||||
return '1.0.1';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
-- watch module schema — version 1.0.0 (up)
|
||||
-- Owns: watch_categories, watch_folders, watch_logs, watch_refresh.
|
||||
-- plex depends on watch and reuses watch_categories + watch_folders.
|
||||
-- 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,
|
||||
@@ -22,6 +24,7 @@ CREATE TABLE IF NOT EXISTS `watch_folders` (
|
||||
`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',
|
||||
@@ -0,0 +1,7 @@
|
||||
-- watch module — teardown (single deletion file)
|
||||
-- Drops every table the module owns. Runs on uninstall. plex is uninstalled
|
||||
-- first (it depends on watch), so its data is already gone by the time these run.
|
||||
DROP TABLE IF EXISTS `watch_refresh`;
|
||||
DROP TABLE IF EXISTS `watch_logs`;
|
||||
DROP TABLE IF EXISTS `watch_folders`;
|
||||
DROP TABLE IF EXISTS `watch_categories`;
|
||||
@@ -1,7 +0,0 @@
|
||||
-- watch module schema — version 1.0.0 (down)
|
||||
-- Reverses 1.0.0.up.sql. Plex is uninstalled first (it depends on watch),
|
||||
-- so its data is already gone by the time these run.
|
||||
DROP TABLE IF EXISTS `watch_refresh`;
|
||||
DROP TABLE IF EXISTS `watch_logs`;
|
||||
DROP TABLE IF EXISTS `watch_folders`;
|
||||
DROP TABLE IF EXISTS `watch_categories`;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- watch module — version delta 1.0.1 (forward-only)
|
||||
-- Upgrades panels installed on an older schema: adds the delete_missing flag to
|
||||
-- watch_folders. Fresh installs get this column from database.sql (master) and
|
||||
-- never run this file. Idempotent, so it is a no-op where the column already
|
||||
-- exists (e.g. from the former core migration 004_add_watch_delete_missing.sql).
|
||||
ALTER TABLE `watch_folders`
|
||||
ADD COLUMN IF NOT EXISTS `delete_missing` tinyint(1) DEFAULT 0 AFTER `active`;
|
||||
Reference in New Issue
Block a user