mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
import enum
|
|
|
|
from sqlalchemy import Column, Integer, String, Float, Enum, TIMESTAMP, Boolean
|
|
from sqlalchemy.orm import declarative_base
|
|
from sqlalchemy.sql import func
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
class MaterialType(enum.Enum):
|
|
suspended_floor_insulation = "suspended_floor_insulation"
|
|
solid_floor_insulation = "solid_floor_insulation"
|
|
external_wall_insulation = "external_wall_insulation"
|
|
internal_wall_insulation = "internal_wall_insulation"
|
|
cavity_wall_insulation = "cavity_wall_insulation"
|
|
|
|
|
|
class DepthUnit(enum.Enum):
|
|
mm = "mm"
|
|
|
|
|
|
class CostUnit(enum.Enum):
|
|
gbp_sq_meter = "gbp_sq_meter"
|
|
|
|
|
|
class RValueUnit(enum.Enum):
|
|
square_meter_kelvin_per_watt = "square_meter_kelvin_per_watt"
|
|
|
|
|
|
class ThermalConductivityUnit(enum.Enum):
|
|
watt_per_meter_kelvin = "watt_per_meter_kelvin"
|
|
|
|
|
|
class Material(Base):
|
|
__tablename__ = 'material'
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
type = Column(Enum(MaterialType, values_callable=lambda x: [e.value for e in x]), nullable=False)
|
|
description = Column(String, nullable=False)
|
|
depths = Column(String) # You may want to use a specific JSON type depending on the database
|
|
depth_unit = Column(Enum(DepthUnit, values_callable=lambda x: [e.value for e in x]), nullable=False)
|
|
cost = Column(String)
|
|
cost_unit = Column(Enum(CostUnit, values_callable=lambda x: [e.value for e in x]), nullable=False)
|
|
r_value_per_mm = Column(Float)
|
|
r_value_unit = Column(Enum(RValueUnit, values_callable=lambda x: [e.value for e in x]), nullable=False)
|
|
thermal_conductivity = Column(Float)
|
|
thermal_conductivity_unit = Column(
|
|
Enum(ThermalConductivityUnit, values_callable=lambda x: [e.value for e in x]),
|
|
nullable=False
|
|
)
|
|
link = Column(String)
|
|
created_at = Column(TIMESTAMP, nullable=False, server_default=func.now())
|
|
is_active = Column(Boolean, nullable=False, default=True)
|