Fixing corrupted Home Assistant energy statistics

TL;DR: My meter dropped offline for ~13 days. Home Assistant's long-term stats came back wrong — a -4,500 kWh bar, a phantom 862 kWh solar spike. The dashboard is a view . The truth is in the statistics table. You fix it with one SELECT to find the damage and one UPDATE to undo it. For a while now, my energy dashboard in Home Assistant reports that my house had produced negative 4,500 kWh in…