28 lines
1.0 KiB
Python
Executable File
28 lines
1.0 KiB
Python
Executable File
import enum
|
|
from sqlalchemy import Column, Integer, String, Boolean, Enum, DateTime, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
|
|
class OrgType(str, enum.Enum):
|
|
INDIVIDUAL = "individual"
|
|
SERVICE = "service"
|
|
FLEET_OWNER = "fleet_owner"
|
|
CLUB = "club"
|
|
|
|
class Organization(Base):
|
|
__tablename__ = "organizations"
|
|
__table_args__ = {"schema": "data"}
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False)
|
|
org_type = Column(Enum(OrgType), default=OrgType.INDIVIDUAL)
|
|
|
|
# Spec 2.2: Az owner_id a magánszemély flottájának tulajdonosát jelöli
|
|
owner_id = Column(Integer, ForeignKey("data.users.id"), nullable=True)
|
|
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
# Kapcsolatok (UserVehicle modell megléte esetén)
|
|
vehicles = relationship("UserVehicle", back_populates="current_org", cascade="all, delete-orphan") |