Cleanup: MB 2.0 Gap Analysis előtti állapot (adatok kizárva)
This commit is contained in:
@@ -1,17 +1,35 @@
|
||||
from sqlalchemy import Column, String, JSON, DateTime, Boolean
|
||||
# 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
|
||||
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).
|
||||
"""
|
||||
__tablename__ = "system_parameters"
|
||||
__table_args__ = {"schema": "data", "extend_existing": True}
|
||||
__table_args__ = (
|
||||
UniqueConstraint('key', 'scope_level', 'scope_id', name='uix_param_scope'),
|
||||
{"schema": "data", "extend_existing": True}
|
||||
)
|
||||
|
||||
key = Column(String, primary_key=True, index=True, nullable=False)
|
||||
# Csoportosítás az Admin felületnek (pl. 'xp', 'scout', 'routing')
|
||||
# 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")
|
||||
value = Column(JSON, nullable=False)
|
||||
|
||||
# A tényleges érték (JSONB-ben tárolva)
|
||||
value = Column(JSONB, nullable=False) # pl. {"FREE": 1, "PREMIUM": 4}
|
||||
|
||||
# --- 🛡️ 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)
|
||||
# Kötelező audit mező: ki módosította utoljára?
|
||||
last_modified_by = Column(String, nullable=True)
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now(), server_default=func.now())
|
||||
Reference in New Issue
Block a user