Add database-level check constraints to ensure scheduled task intervals are always positive for both Postgres and SQLite. Update admin API and UI to support sub-minute intervals and stricter validation. Refactor scheduled task update logic to upsert rows, ensuring tasks can be updated even if not yet present in the database. Improve temporary upload cleanup to delete in paginated batches. Enhance tests to cover new constraints and update behaviors.
15 lines
571 B
SQL
15 lines
571 B
SQL
CREATE TABLE `scheduled_tasks` (
|
|
`key` text PRIMARY KEY NOT NULL,
|
|
`enabled` integer DEFAULT true NOT NULL,
|
|
`interval_ms` integer NOT NULL,
|
|
`last_status` text DEFAULT 'idle' NOT NULL,
|
|
`last_run_at` integer,
|
|
`last_duration_ms` integer,
|
|
`last_error` text,
|
|
`last_result_json` text,
|
|
`next_run_at` integer,
|
|
`run_requested` integer DEFAULT false NOT NULL,
|
|
`running_since` integer,
|
|
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
|
|
CONSTRAINT "scheduled_tasks_interval_ms_positive" CHECK("scheduled_tasks"."interval_ms" > 0)
|
|
);
|