Migration adds tables that existed in models/ but were never included in alembic history: - ai_ops: device_health_scores, anomaly_detections, diagnostic_reports, maintenance_predictions, ops_insights - energy_strategy: tou_pricing, tou_pricing_periods, energy_strategies, strategy_executions, monthly_cost_reports - weather: weather_data, weather_config - prediction: prediction_tasks, prediction_results, optimization_schedules Without this migration, fresh deploys would 500 on these endpoints: - /api/v1/ai-ops/health, /ai-ops/dashboard - /api/v1/strategy/pricing - /api/v1/prediction/forecast - /api/v1/weather/current Discovered during Z-Park demo deployment on xie_openclaw1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Float, DateTime, JSON
|
|
from sqlalchemy.sql import func
|
|
from app.core.database import Base
|
|
|
|
|
|
class MeterReading(Base):
|
|
"""电表读数时序数据"""
|
|
__tablename__ = "meter_readings"
|
|
|
|
time = Column(DateTime(timezone=True), primary_key=True, nullable=False)
|
|
meter_id = Column(Integer, primary_key=True, nullable=False)
|
|
meter_name = Column(String(100))
|
|
forward_active_energy = Column(Float) # 正向有功电能 kWh
|
|
reverse_active_energy = Column(Float) # 反向有功电能 kWh
|
|
active_power = Column(Float) # 有功功率 kW
|
|
reactive_power = Column(Float) # 无功功率 kvar
|
|
power_factor = Column(Float) # 功率因数
|
|
voltage_a = Column(Float) # A相电压 V
|
|
voltage_b = Column(Float) # B相电压 V
|
|
voltage_c = Column(Float) # C相电压 V
|
|
current_a = Column(Float) # A相电流 A
|
|
current_b = Column(Float) # B相电流 A
|
|
current_c = Column(Float) # C相电流 A
|
|
raw_json = Column(JSON) # 原始数据包
|