STABLE: Final schema sync, optimized gitignore
This commit is contained in:
@@ -1,35 +1,29 @@
|
||||
# backend/app/models/system.py
|
||||
import enum
|
||||
from sqlalchemy import Column, String, DateTime, Boolean, text, UniqueConstraint, Integer
|
||||
from sqlalchemy.dialects.postgresql import JSONB # <-- JSONB-t használunk a stabilitásért
|
||||
# /opt/docker/dev/service_finder/backend/app/models/system.py
|
||||
from datetime import datetime
|
||||
from typing import Optional, Any
|
||||
from sqlalchemy import String, Integer, Boolean, DateTime, text, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.base_class import Base
|
||||
|
||||
class SystemParameter(Base):
|
||||
"""
|
||||
Központi, dinamikus konfigurációs tábla.
|
||||
Támogatja a többlépcsős felülbírálást (Global -> Country -> Region -> Individual).
|
||||
"""
|
||||
""" Dinamikus konfigurációs motor (Global -> Org -> User). """
|
||||
__tablename__ = "system_parameters"
|
||||
__table_args__ = (
|
||||
UniqueConstraint('key', 'scope_level', 'scope_id', name='uix_param_scope'),
|
||||
{"schema": "data", "extend_existing": True}
|
||||
{"extend_existing": True}
|
||||
)
|
||||
|
||||
# Technikai ID, hogy a 'key' ne legyen Primary Key, így engedve a hierarchiát
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
|
||||
key = Column(String, index=True, nullable=False) # pl. 'VEHICLE_LIMIT'
|
||||
category = Column(String, index=True, server_default="general")
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
key: Mapped[str] = mapped_column(String, index=True)
|
||||
category: Mapped[str] = mapped_column(String, server_default="general", index=True)
|
||||
value: Mapped[dict] = mapped_column(JSONB, nullable=False)
|
||||
|
||||
# A tényleges érték (JSONB-ben tárolva)
|
||||
value = Column(JSONB, nullable=False) # pl. {"FREE": 1, "PREMIUM": 4}
|
||||
scope_level: Mapped[str] = mapped_column(String(30), server_default=text("'global'"), index=True)
|
||||
scope_id: Mapped[Optional[str]] = mapped_column(String(50))
|
||||
|
||||
# --- 🛡️ HIERARCHIKUS SZINTEK ---
|
||||
scope_level = Column(String(30), server_default=text("'global'"), index=True)
|
||||
scope_id = Column(String(50), nullable=True)
|
||||
|
||||
is_active = Column(Boolean, default=True)
|
||||
description = Column(String)
|
||||
last_modified_by = Column(String, nullable=True)
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now())
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
description: Mapped[Optional[str]] = mapped_column(String)
|
||||
last_modified_by: Mapped[Optional[str]] = mapped_column(String)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now())
|
||||
Reference in New Issue
Block a user