11-- Profilarr Database Schema
22-- This file documents the current database schema after all migrations
33-- DO NOT execute this file directly - use migrations instead
4- -- Last updated: 2026-01-28
4+ -- Last updated: 2026-02-20
55
66-- ==============================================================================
77-- TABLE: migrations
@@ -276,7 +276,7 @@ CREATE TABLE database_instances (
276276-- ==============================================================================
277277-- TABLE: upgrade_configs
278278-- Purpose: Store upgrade configuration per arr instance for automated quality upgrades
279- -- Migration: 011_create_upgrade_configs.ts, 012_add_upgrade_last_run.ts, 013_add_upgrade_dry_run.ts
279+ -- Migration: 011_create_upgrade_configs.ts, 012_add_upgrade_last_run.ts, 013_add_upgrade_dry_run.ts, 051_cron_scheduling.ts
280280-- ==============================================================================
281281
282282CREATE TABLE upgrade_configs (
@@ -288,7 +288,7 @@ CREATE TABLE upgrade_configs (
288288 -- Core settings
289289 enabled INTEGER NOT NULL DEFAULT 0 , -- Master on/off switch
290290 dry_run INTEGER NOT NULL DEFAULT 0 , -- 1=dry run mode, 0=normal (Migration 013)
291- schedule INTEGER NOT NULL DEFAULT 360 , -- Run interval in minutes (default 6 hours )
291+ cron TEXT NOT NULL DEFAULT ' 0 */6 * * * ' , -- Cron expression (Migration 051, replaced schedule )
292292 filter_mode TEXT NOT NULL DEFAULT ' round_robin' , -- 'round_robin' or 'random'
293293
294294 -- Filters (stored as JSON array of FilterConfig objects)
@@ -297,6 +297,7 @@ CREATE TABLE upgrade_configs (
297297 -- State tracking
298298 current_filter_index INTEGER NOT NULL DEFAULT 0 , -- For round-robin mode
299299 last_run_at DATETIME, -- When upgrade job last ran (Migration 012)
300+ next_run_at TEXT , -- Next scheduled run (Migration 051)
300301
301302 -- Metadata
302303 created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
@@ -614,7 +615,7 @@ CREATE INDEX idx_pattern_match_cache_created_at ON pattern_match_cache(created_a
614615-- ==============================================================================
615616-- TABLE: arr_rename_settings
616617-- Purpose: Store rename configuration per arr instance for bulk file/folder renaming
617- -- Migration: 024_create_arr_rename_settings.ts, 025_add_rename_notification_mode.ts
618+ -- Migration: 024_create_arr_rename_settings.ts, 025_add_rename_notification_mode.ts, 051_cron_scheduling.ts
618619-- ==============================================================================
619620
620621CREATE TABLE arr_rename_settings (
@@ -631,7 +632,8 @@ CREATE TABLE arr_rename_settings (
631632
632633 -- Job scheduling
633634 enabled INTEGER NOT NULL DEFAULT 0 , -- Master on/off switch for scheduled job
634- schedule INTEGER NOT NULL DEFAULT 1440 , -- Run interval in minutes (default 24 hours)
635+ cron TEXT NOT NULL DEFAULT ' 0 0 * * *' , -- Cron expression (Migration 051, replaced schedule)
636+ next_run_at TEXT , -- Next scheduled run (Migration 051)
635637 last_run_at DATETIME, -- When rename job last ran
636638
637639 -- Metadata
@@ -644,6 +646,36 @@ CREATE TABLE arr_rename_settings (
644646-- Arr rename settings indexes (Migration: 024_create_arr_rename_settings.ts)
645647CREATE INDEX idx_arr_rename_settings_arr_instance ON arr_rename_settings(arr_instance_id);
646648
649+ -- ==============================================================================
650+ -- TABLE: arr_cleanup_settings
651+ -- Purpose: Store cleanup scheduling configuration per arr instance
652+ -- Migration: 052_create_arr_cleanup_settings.ts
653+ -- ==============================================================================
654+
655+ CREATE TABLE arr_cleanup_settings (
656+ id INTEGER PRIMARY KEY AUTOINCREMENT,
657+
658+ -- Relationship (one config per arr instance)
659+ arr_instance_id INTEGER NOT NULL UNIQUE,
660+
661+ -- Settings
662+ enabled INTEGER NOT NULL DEFAULT 0 , -- Master on/off switch
663+ cron TEXT NOT NULL DEFAULT ' 0 0 * * 0' , -- Cron expression (default: weekly Sunday midnight)
664+
665+ -- State tracking
666+ next_run_at TEXT , -- Next scheduled run
667+ last_run_at TEXT , -- When cleanup job last ran
668+
669+ -- Metadata
670+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
671+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
672+
673+ FOREIGN KEY (arr_instance_id) REFERENCES arr_instances(id) ON DELETE CASCADE
674+ );
675+
676+ -- Arr cleanup settings indexes (Migration: 052_create_arr_cleanup_settings.ts)
677+ CREATE INDEX idx_arr_cleanup_settings_instance ON arr_cleanup_settings(arr_instance_id);
678+
647679-- ==============================================================================
648680-- TABLE: upgrade_runs
649681-- Purpose: Store upgrade run history for each arr instance
@@ -665,7 +697,7 @@ CREATE TABLE upgrade_runs (
665697 dry_run INTEGER NOT NULL DEFAULT 0 , -- 1=dry run, 0=live
666698
667699 -- Config snapshot (flat for queryability)
668- schedule INTEGER NOT NULL , -- Schedule interval in minutes
700+ cron TEXT NOT NULL , -- Cron expression (Migration 051, renamed from schedule)
669701 filter_mode TEXT NOT NULL , -- 'round_robin' or 'random'
670702 filter_name TEXT NOT NULL , -- Name of the filter used
671703
0 commit comments