from typing import Optional
from sqlmodel import Field, SQLModel
from datetime import datetime


class Meter(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    serial_number: str


class Measurement(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    meter_id: Optional[int] = Field(default=None, foreign_key="meter.id")
    capture_time: datetime = Field()
    voltage_phase_1: float = Field(default=0.0)
    voltage_phase_2: float = Field(default=0.0)
    voltage_phase_3: float = Field(default=0.0)
    power: float = Field(default=0.0)
    thd_1: float = Field(default=0.0)
    thd_2: float = Field(default=0.0)
    thd_3: float = Field(default=0.0)
    thd_4: float = Field(default=0.0)
    thd_5: float = Field(default=0.0)
    thd_6: float = Field(default=0.0)
    thd_7: float = Field(default=0.0)
    thd_8: float = Field(default=0.0)
    thd_9: float = Field(default=0.0)
    thd_10: float = Field(default=0.0)


class Label(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str =  Field()
    color: str =  Field()


class LabelAssignment(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    label_id: Optional[int] = Field(default=None, foreign_key="label.id")
    meter_id: Optional[int] = Field(default=None, foreign_key="meter.id")
    start_time: datetime = Field()
    end_time: datetime = Field()

sqlmodel.Field
[((156, 193), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (161, 193), False, 'from sqlmodel import Field, SQLModel\n'), ((284, 321), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (289, 321), False, 'from sqlmodel import Field, SQLModel\n'), ((352, 395), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""meter.id"""'}), "(default=None, foreign_key='meter.id')\n", (357, 395), False, 'from sqlmodel import Field, SQLModel\n'), ((425, 432), 'sqlmodel.Field', 'Field', ([], {}), '()\n', (430, 432), False, 'from sqlmodel import Field, SQLModel\n'), ((462, 480), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (467, 480), False, 'from sqlmodel import Field, SQLModel\n'), ((510, 528), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (515, 528), False, 'from sqlmodel import Field, SQLModel\n'), ((558, 576), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (563, 576), False, 'from sqlmodel import Field, SQLModel\n'), ((596, 614), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (601, 614), False, 'from sqlmodel import Field, SQLModel\n'), ((634, 652), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (639, 652), False, 'from sqlmodel import Field, SQLModel\n'), ((672, 690), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (677, 690), False, 'from sqlmodel import Field, SQLModel\n'), ((710, 728), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (715, 728), False, 'from sqlmodel import Field, SQLModel\n'), ((748, 766), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (753, 766), False, 'from sqlmodel import Field, SQLModel\n'), ((786, 804), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (791, 804), False, 'from sqlmodel import Field, SQLModel\n'), ((824, 842), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (829, 842), False, 'from sqlmodel import Field, SQLModel\n'), ((862, 880), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (867, 880), False, 'from sqlmodel import Field, SQLModel\n'), ((900, 918), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (905, 918), False, 'from sqlmodel import Field, SQLModel\n'), ((938, 956), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (943, 956), False, 'from sqlmodel import Field, SQLModel\n'), ((977, 995), 'sqlmodel.Field', 'Field', ([], {'default': '(0.0)'}), '(default=0.0)\n', (982, 995), False, 'from sqlmodel import Field, SQLModel\n'), ((1057, 1094), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (1062, 1094), False, 'from sqlmodel import Field, SQLModel\n'), ((1112, 1119), 'sqlmodel.Field', 'Field', ([], {}), '()\n', (1117, 1119), False, 'from sqlmodel import Field, SQLModel\n'), ((1138, 1145), 'sqlmodel.Field', 'Field', ([], {}), '()\n', (1143, 1145), False, 'from sqlmodel import Field, SQLModel\n'), ((1217, 1254), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (1222, 1254), False, 'from sqlmodel import Field, SQLModel\n'), ((1285, 1328), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""label.id"""'}), "(default=None, foreign_key='label.id')\n", (1290, 1328), False, 'from sqlmodel import Field, SQLModel\n'), ((1359, 1402), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'foreign_key': '"""meter.id"""'}), "(default=None, foreign_key='meter.id')\n", (1364, 1402), False, 'from sqlmodel import Field, SQLModel\n'), ((1430, 1437), 'sqlmodel.Field', 'Field', ([], {}), '()\n', (1435, 1437), False, 'from sqlmodel import Field, SQLModel\n'), ((1463, 1470), 'sqlmodel.Field', 'Field', ([], {}), '()\n', (1468, 1470), False, 'from sqlmodel import Field, SQLModel\n')]