File size: 3,152 Bytes
b613c13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"""
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()