=== Database Connection Test ===
✓ Database connection successful

=== Table Structure Test ===
Table 'device_metrics' structure:
- id: int(11) (Null: NO, Default: )
- device_id: varchar(50) (Null: NO, Default: )
- total_cycles: bigint(20) (Null: NO, Default: )
- waste_bags_saved: decimal(10,2) (Null: NO, Default: )
- co2_emissions_diverted: decimal(10,2) (Null: NO, Default: )
- last_emptied_time: bigint(20) (Null: NO, Default: )
- month_start_time: bigint(20) (Null: NO, Default: )
- data_version: smallint(6) (Null: NO, Default: )
- checksum: int(11) (Null: NO, Default: )
- sync_time: timestamp (Null: NO, Default: current_timestamp())

=== Current Data Test ===
Total rows in device_metrics: 1
Latest 3 rows:
- ID: 7819, Device: SEPURA_04830876D020, Cycles: 1500, Bags: 45.50

=== Simple Insert Test ===
✗ Test insert failed: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`sepura5_SepuraHome_DB_v2`.`device_metrics`, CONSTRAINT `fk_device_metrics_device` FOREIGN KEY (`device_id`) REFERENCES `devices` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE)

=== Test Complete ===
