Files
Warracker/backend/migrations/039_update_language_constraint.sql
sassanix 60239bd637 Fix Apprise notification system, scheduler stability, and email configuration
Fixes & Enhancements

* Resolved five critical Apprise notification issues:
  • Ensured configuration reload during scheduled jobs
  • Fixed warranty data fetching for Apprise-only users
  • Refactored notification dispatch logic with dedicated helpers
  • Corrected handler scoping via Flask app context
  • Wrapped scheduler jobs with Flask app context to prevent context errors
  → Verified: Scheduled Apprise notifications now work reliably for "Apprise only" and "Both" channels.

* Added support for SMTP\_FROM\_ADDRESS environment variable, allowing sender address customization independent of SMTP username. (PR #115)

* Fixed duplicate scheduled notifications in multi-worker environments:
  • Strengthened should\_run\_scheduler() logic
  • Now guarantees exactly one scheduler instance across all Gunicorn modes.

* Fixed stale database connection handling in scheduled jobs:
  • Fresh connection acquired each run, properly released via try/finally
  • Eliminates "server closed the connection" errors.

* Definitive scheduler logic fix for all memory modes (ultra-light, optimized, performance):
  • Single-worker runs scheduler if GUNICORN\_WORKER\_ID is unset
  • Multi-worker: only worker 0 runs scheduler.

Impact

* Apprise and Email notifications are now stable, reliable, and production-ready
* No more duplicate or missed notifications across all memory modes
* Improved system efficiency and robustness
2025-08-24 12:34:40 -03:00

30 lines
1.2 KiB
SQL

-- Migration: Update preferred_language constraint to include new languages
-- Date: 2024-12-26
-- Description: Update the constraint to allow new language codes: cs, nl, hi, fa, ar
-- Drop the existing constraint
DO $$
BEGIN
IF EXISTS (
SELECT 1 FROM information_schema.table_constraints
WHERE constraint_name = 'chk_users_preferred_language'
AND table_name = 'users'
) THEN
ALTER TABLE users DROP CONSTRAINT chk_users_preferred_language;
RAISE NOTICE 'Dropped existing preferred_language constraint';
ELSE
RAISE NOTICE 'preferred_language constraint does not exist, skipping drop';
END IF;
END $$;
-- Add updated constraint with all supported languages
DO $$
BEGIN
ALTER TABLE users
ADD CONSTRAINT chk_users_preferred_language
CHECK (preferred_language IN ('en', 'fr', 'es', 'de', 'it', 'cs', 'nl', 'hi', 'fa', 'ar'));
RAISE NOTICE 'Added updated preferred_language constraint with new languages';
END $$;
-- Update comment to reflect new supported languages
COMMENT ON COLUMN users.preferred_language IS 'User preferred language for UI localization (ISO 639-1 code): en, fr, es, de, it, cs, nl, hi, fa, ar';