Files
plantillas-proyectos/backend/api/v1/modules/public/code_pedimento_regimens/models.py
acazares 2a10d7d267 feat: Add frontend and backend initialization scripts, implement Keycloak and PostgreSQL setup
- 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.
2025-10-19 00:14:06 -05:00

31 lines
1.4 KiB
Python

from typing import Optional
from sqlalchemy import String, Integer, ForeignKey, ForeignKeyConstraint, PrimaryKeyConstraint
from sqlalchemy.orm import mapped_column, Mapped, relationship
from core.database import Base
class CodePedimentoRegimen(Base):
__tablename__ = "code_pedimento_regimens" #GClavePedRegimen
__table_args__ = (
ForeignKeyConstraint(['pedimento_code'], ['public.pedimento_codes.code'], name='fk_claveped'),
ForeignKeyConstraint(['regimen_code'], ['public.pedimento_regimens.code'], name='fk_regimenped'),
PrimaryKeyConstraint('id', name='clave_pedimento_regimens_pkey'),
{"schema": "public"}
)
id: Mapped[int] = mapped_column(Integer)
pedimento_code: Mapped[str] = mapped_column(String(3), nullable=False)
regimen_code: Mapped[Optional[str]] = mapped_column(String(3), nullable=False)
type_code: Mapped[Optional[str]] = mapped_column(String(1)) # si aplica un tipo de relación
# Relaciones ORM
#GClavePed
pedimento: Mapped['PedimentoCode'] = relationship(
'PedimentoCode', back_populates='regimens'
)
#GRegimenPed
regimen: Mapped[Optional['RegimenPedimento']] = relationship(
'RegimenPedimento', back_populates='claves_pedimento'
)
def __repr__(self):
return f"<ClavePedimentoRegimen(pedimento={self.pedimento_code}, regimen={self.regimen_code}, type={self.type_code})>"