mirror of
https://github.com/sassanix/Warracker.git
synced 2026-01-05 21:19:42 -06:00
* Added Model Number field to warranties (backend + frontend integration) * Expanded localization: added Polish and Hebrew (with RTL), completed warranty claim translations for all locales * Enhanced search: Model Number now searchable on Home and Status pages * Improved Status page with Archived warranties filtering and display * Fixed Global view logic for archived warranties and Model Number visibility * Corrected missing Model Number translations across all languages * Improved Add Warranty modal responsiveness on small screens * Fixed document URL visibility bug and Chrome horizontal scrollbar issue * Updated major dependencies (Python 3.14, gevent 25.9.1, Flask 3.1.2, etc.) * Added Reddit community link and localization on About page * PWA and cache updates for faster rollout and consistent asset refresh
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
import logging
|
|
|
|
try:
|
|
# Prefer importing the live list so this migration reflects current support
|
|
from backend.localization import SUPPORTED_LANGUAGES
|
|
except Exception:
|
|
# Fallback list including Polish
|
|
SUPPORTED_LANGUAGES = ['en', 'fr', 'es', 'de', 'it', 'cs', 'nl', 'hi', 'fa', 'ar', 'ru', 'uk', 'zh_CN', 'zh_HK', 'ja', 'pt', 'ko', 'tr', 'pl']
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def apply_migration(conn):
|
|
"""Drop and recreate preferred_language CHECK constraint to include new languages (adds 'pl')."""
|
|
cur = conn.cursor()
|
|
try:
|
|
logger.info("Dropping existing 'chk_users_preferred_language' constraint if it exists…")
|
|
cur.execute(
|
|
"""
|
|
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;
|
|
END IF;
|
|
END $$;
|
|
"""
|
|
)
|
|
|
|
# Build the IN list from supported languages
|
|
language_list_sql = ", ".join([f"'{lang}'" for lang in SUPPORTED_LANGUAGES])
|
|
|
|
logger.info("Creating updated 'chk_users_preferred_language' constraint…")
|
|
cur.execute(
|
|
f"""
|
|
ALTER TABLE users
|
|
ADD CONSTRAINT chk_users_preferred_language
|
|
CHECK (preferred_language IN ({language_list_sql}));
|
|
"""
|
|
)
|
|
|
|
cur.execute(
|
|
f"""
|
|
COMMENT ON COLUMN users.preferred_language IS 'User preferred language for UI localization (ISO 639-1 code): {', '.join(SUPPORTED_LANGUAGES)}';
|
|
"""
|
|
)
|
|
|
|
conn.commit()
|
|
logger.info("Language constraint updated successfully.")
|
|
except Exception as e:
|
|
conn.rollback()
|
|
logger.error(f"Error updating language constraint: {e}")
|
|
raise
|
|
finally:
|
|
cur.close()
|
|
|
|
|