TT-003: complete request-module integration into modular platform
- integrated request-module into module registry - moved backend into modules/request-module - added manifest.json and module.py - implemented dynamic router mounting - implemented dynamic static mounting - removed direct dependencies from platform core - verified startup with request-module - verified startup without request-module - added implementation_report_003.md
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
"""Validate migration data integrity."""
|
||||
|
||||
import psycopg2
|
||||
from psycopg2.extras import RealDictCursor
|
||||
import json
|
||||
|
||||
|
||||
def validate_migration():
|
||||
"""Validate data integrity after migration."""
|
||||
|
||||
conn = psycopg2.connect(
|
||||
host='localhost',
|
||||
database='service_request',
|
||||
user='user',
|
||||
password='password'
|
||||
)
|
||||
cursor = conn.cursor(cursor_factory=RealDictCursor)
|
||||
|
||||
try:
|
||||
print("=== Migration Validation ===\n")
|
||||
|
||||
# Check row counts
|
||||
print("Checking row counts...")
|
||||
tables = [
|
||||
('categories', 'Category'),
|
||||
('priorities', 'Priority'),
|
||||
('statuses', 'Status'),
|
||||
('companies', 'Company'),
|
||||
('locations', 'Location'),
|
||||
('departments', 'Department'),
|
||||
('users', 'User'),
|
||||
('tickets', 'Ticket'),
|
||||
('comments', 'Comment')
|
||||
]
|
||||
|
||||
row_counts = []
|
||||
for table_name, display_name in tables:
|
||||
cursor.execute(f"SELECT COUNT(*) as count FROM {table_name}")
|
||||
count = cursor.fetchone()['count']
|
||||
row_counts.append((display_name, count))
|
||||
print(f" {display_name}: {count}")
|
||||
|
||||
# Check unique keys
|
||||
print("\nChecking unique keys...")
|
||||
unique_checks = [
|
||||
('users', 'email', 'email'),
|
||||
('categories', 'name', 'category'),
|
||||
('priorities', 'name', 'priority'),
|
||||
('statuses', 'name', 'status')
|
||||
]
|
||||
|
||||
for table_name, column_name, display_name in unique_checks:
|
||||
cursor.execute(f"SELECT COUNT(DISTINCT {column_name}) FROM {table_name}")
|
||||
count = cursor.fetchone()['count']
|
||||
print(f" Unique {display_name}s: {count}")
|
||||
|
||||
# Check ticket status distribution
|
||||
print("\nTicket status distribution:")
|
||||
cursor.execute("""
|
||||
SELECT s.name, COUNT(t.id) as count
|
||||
FROM statuses s
|
||||
LEFT JOIN tickets t ON s.id = t.status_id
|
||||
GROUP BY s.name
|
||||
ORDER BY count DESC
|
||||
""")
|
||||
for row in cursor.fetchall():
|
||||
print(f" {row['name']}: {row['count']}")
|
||||
|
||||
# Check priority distribution
|
||||
print("\nTicket priority distribution:")
|
||||
cursor.execute("""
|
||||
SELECT p.name, COUNT(t.id) as count
|
||||
FROM priorities p
|
||||
LEFT JOIN tickets t ON p.id = t.priority_id
|
||||
GROUP BY p.name
|
||||
ORDER BY count DESC
|
||||
""")
|
||||
for row in cursor.fetchall():
|
||||
print(f" {row['name']}: {row['count']}")
|
||||
|
||||
# Check active vs closed tickets
|
||||
print("\nTicket lifecycle:")
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
COUNT(CASE WHEN closed_at IS NULL THEN 1 END) as open_tickets,
|
||||
COUNT(CASE WHEN closed_at IS NOT NULL THEN 1 END) as closed_tickets,
|
||||
COUNT(*) as total_tickets
|
||||
FROM tickets
|
||||
""")
|
||||
row = cursor.fetchone()
|
||||
print(f" Open: {row['open_tickets']}")
|
||||
print(f" Closed: {row['closed_tickets']}")
|
||||
print(f" Total: {row['total_tickets']}")
|
||||
|
||||
# Check user statistics
|
||||
print("\nUser statistics:")
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
COUNT(CASE WHEN is_active THEN 1 END) as active_users,
|
||||
COUNT(*) as total_users
|
||||
FROM users
|
||||
""")
|
||||
row = cursor.fetchone()
|
||||
print(f" Active: {row['active_users']}")
|
||||
print(f" Total: {row['total_users']}")
|
||||
|
||||
print("\n✓ Validation complete!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n✗ Validation error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
|
||||
def main():
|
||||
"""Main execution function."""
|
||||
|
||||
print("Running migration validation...\n")
|
||||
|
||||
try:
|
||||
validate_migration()
|
||||
except Exception as e:
|
||||
print(f"\nError: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user