-- Clean up garbage data in anos_formaturas (Company names, empty strings, etc.) -- Keep only patterns like 2024.1, 2024.2, etc. and maybe 2025.3 if used (User DB showed it). -- Using regex: starts with 4 digits, dot, digit. -- Clean dependencies in cadastro_fot first to avoid FK violations DELETE FROM cadastro_fot WHERE ano_formatura_id IN ( SELECT id FROM anos_formaturas WHERE ano_semestre !~ '^\d{4}\.\d+$' ); -- Delete the garbage years DELETE FROM anos_formaturas WHERE ano_semestre !~ '^\d{4}\.\d+$';