CC1 audit fixes #6/#8/#9 from CONSOLIDATED.md
#9 sportas trailing-slash (verified clean): Frontend constructs /sportas/{id}/profil cleanly (sport2.html:L1582). Live test: 200 on /sportas/449/profil; 307 on trailing-slash variant (FastAPI auto-redirect, harmless). No fix needed. #8 [VERIFY]/[UNRESOLVED] klubovi surfaced to audit log: 3 manual_review klubovi (2619 Čavle, 2630 Opatija, 4426 empty) inserted into pgz_sport.sys_audit with action='klub.manual_review_pending', visible in /audit page for human triage. Total audit rows: 633. #6 backup-table archival: Moved 26 *_backup_*/*_premerge_*/*_pre_*/*_dedup_*/*_deprecated_*/*_garbage_* tables (~97k rows) from pgz_sport → pgz_sport_archive schema. - Snapshot dump: _audit/db_snapshots/backup_tables_20260505_085057.sql.gz (56 MB) - Script: scripts/archive_backup_tables.sql (idempotent, with rollback) - pgz_sport canonical tables: 112 → 86 - All live API endpoints still 200, db=ok, errors_logged stable at 23 - Josip Zec test 257/182/15 still PASS .gitignore: exclude _audit/db_snapshots/ (large pg_dump archives) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
-- archive_backup_tables.sql — moved 26 backup/snapshot tables out of pgz_sport
|
||||
-- Author: cc1@rinet.one Date: 2026-05-05
|
||||
-- Re-runnable (idempotent — only moves tables that still match pattern in pgz_sport)
|
||||
--
|
||||
-- Snapshot dump kept at: _audit/db_snapshots/backup_tables_20260505_085057.sql.gz (56 MB)
|
||||
--
|
||||
-- Patterns matched: _backup_ _premerge_ _pre_ _dedup_ _deprecated_ _garbage_
|
||||
-- _pre_godisnjak _pre_b_switch
|
||||
--
|
||||
-- After this:
|
||||
-- pgz_sport canonical tables: 86 (was 112)
|
||||
-- pgz_sport_archive holds: 26
|
||||
-- ~97k rows of stale data archived (no DROP — recoverable via ALTER ... SET SCHEMA back)
|
||||
--
|
||||
-- Rollback any single table:
|
||||
-- ALTER TABLE pgz_sport_archive.<name> SET SCHEMA pgz_sport;
|
||||
--
|
||||
-- Rollback all:
|
||||
-- DO $$ DECLARE r record; BEGIN
|
||||
-- FOR r IN SELECT relname FROM pg_stat_user_tables WHERE schemaname='pgz_sport_archive' LOOP
|
||||
-- EXECUTE format('ALTER TABLE pgz_sport_archive.%I SET SCHEMA pgz_sport', r.relname);
|
||||
-- END LOOP; END $$;
|
||||
--
|
||||
-- Permanent drop (after confidence period):
|
||||
-- DROP SCHEMA pgz_sport_archive CASCADE;
|
||||
|
||||
BEGIN;
|
||||
CREATE SCHEMA IF NOT EXISTS pgz_sport_archive;
|
||||
|
||||
DO $$
|
||||
DECLARE r record;
|
||||
BEGIN
|
||||
FOR r IN
|
||||
SELECT relname FROM pg_stat_user_tables
|
||||
WHERE schemaname='pgz_sport'
|
||||
AND (relname ~ '_backup_|_premerge_|_pre_|_dedup_|_deprecated_|_garbage_|_pre_godisnjak|_pre_b_switch')
|
||||
ORDER BY relname
|
||||
LOOP
|
||||
EXECUTE format('ALTER TABLE pgz_sport.%I SET SCHEMA pgz_sport_archive', r.relname);
|
||||
RAISE NOTICE 'moved %', r.relname;
|
||||
END LOOP;
|
||||
END $$;
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user