""" verify_migration.py — Post-migration data integrity verification. Run AFTER etl_sheets_to_postgres.py completes. Compares row counts, checksums, and key data points between Google Sheets (source) and PostgreSQL (destination). Usage: python verify_migration.py """ import hashlib import json from datetime import datetime # ─── Configuration ─────────────────────────────────────────────────────────── SHEET_NAMES = [ "Data Utama", "Katalog Talenta (B2B)", "Companies", "Clients", "Transactions", "Unlocks", "Interviews", "Job_Postings", "Mediated_Chats", "Mitra_LPK", "Mitra_LPK_Courses", "Sponsor_Campaigns", "Campaign_Participants", "Vouchers", "Certificates", "Blog", "Knowledge Base", "Admins", ] TABLE_MAP = { "Data Utama": "talents", "Katalog Talenta (B2B)": "talent_catalog", "Companies": "companies", "Clients": "client_accounts", "Transactions": "transactions", "Unlocks": "profile_unlocks", "Interviews": "interviews", "Job_Postings": "job_postings", "Mediated_Chats": "mediated_chats", "Mitra_LPK": "lpk_partners", "Mitra_LPK_Courses": "lpk_courses", "Sponsor_Campaigns": "sponsor_campaigns", "Campaign_Participants": "campaign_participants", "Vouchers": "vouchers", "Certificates": "certificates", "Blog": "blog_posts", "Knowledge Base": "knowledge_base", "Admins": "admins", } def verify(): """ Run post-migration verification. Prints a report to stdout. """ print(f"{\'='*60}") print(f" BRIGAWAN MIGRATION VERIFICATION REPORT") print(f" {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") print(f"{\'='*60}") print() # TODO: Connect to Google Sheets # TODO: Connect to PostgreSQL results = [] for sheet_name, table_name in TABLE_MAP.items(): # Placeholder: actual comparison logic goes here results.append({ "sheet": sheet_name, "table": table_name, "status": "PENDING", "sheet_rows": 0, "db_rows": 0, "match": False, "issues": ["Not yet connected to data sources"], }) # ─── Report ─────────────────────────────────────────────────────────── passed = 0 failed = 0 for r in results: status_icon = "PASS" if r["match"] else "FAIL" print(f" [{status_icon}] {r['sheet']:30s} → {r['table']:25s} " f"(Sheet: {r['sheet_rows']:5d} | DB: {r['db_rows']:5d})") if r["match"]: passed += 1 else: failed += 1 for issue in r["issues"]: print(f" ⚠ {issue}") print() print(f" Summary: {passed} passed, {failed} failed, " f"{len(results)} total") print(f"{\'='*60}") return results if __name__ == "__main__": verify()