- Implemented SvelteKit frontend with authentication callback handling. - Created demo routes and paraglide localization functionality. - Added health check and entrypoint scripts for backend services. - Established PostgreSQL and Keycloak initialization scripts with health checks. - Introduced models for database schema using SQLAlchemy. - Configured Vite and SvelteKit for development and testing environments. - Added health check script to verify service statuses and resource usage. - Created Docker entrypoint scripts for seamless service startup.
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""
|
|
Modelos ORM para gestión de tenants
|
|
"""
|
|
from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, Enum as SQLEnum
|
|
from sqlalchemy.sql import func
|
|
from core.database import Base
|
|
import enum
|
|
|
|
|
|
class TenantType(enum.Enum):
|
|
"""Tipo de tenant según tamaño y necesidades"""
|
|
SHARED = "shared" # BD compartida
|
|
DEDICATED = "dedicated" # BD dedicada
|
|
|
|
|
|
class Tenant(Base):
|
|
"""
|
|
Modelo de Tenant - Cliente/Organización en el sistema
|
|
Cada tenant puede tener BD compartida o dedicada
|
|
"""
|
|
__tablename__ = "tenants"
|
|
__table_args__ = {"schema": "a76"}
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(255), nullable=False, index=True)
|
|
slug = Column(String(100), unique=True, nullable=False, index=True)
|
|
|
|
# Tipo de tenant (compartido o dedicado)
|
|
type = Column(SQLEnum(TenantType), default=TenantType.SHARED, nullable=False)
|
|
|
|
# Keycloak realm asociado
|
|
keycloak_realm = Column(String(255), unique=True, nullable=False)
|
|
|
|
# Configuración de BD dedicada (JSON string o NULL si usa BD compartida)
|
|
db_config = Column(Text, nullable=True) # JSON: {host, port, name, user, password}
|
|
|
|
# Información de contacto
|
|
contact_name = Column(String(255))
|
|
contact_email = Column(String(255))
|
|
contact_phone = Column(String(50))
|
|
|
|
# Estado
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), nullable=False)
|
|
|
|
def __repr__(self):
|
|
return f"<Tenant(id={self.id}, name={self.name}, type={self.type.value})>"
|