Files
telegram_new_socias/models/vanity_attendance_models.py
google-labs-jules[bot] 4e2b6335a6 feat: Implement multi-database architecture
This commit introduces a three-database architecture to the application,
as specified in the `db_logic.md` file.

The changes include:
- A SQL initialization script (`db/init/init.sql`) to create the
  `USERS_ALMA`, `vanity_hr`, and `vanity_attendance` databases and their
  respective tables.
- SQLAlchemy models for all tables, organized into separate files
  within the `models` directory.
- Refactoring of the database connection logic in `modules/database.py`
  to support connections to all three databases.
- Creation of a `modules/logger.py` to handle request logging to the
  `USERS_ALMA` database.
- Updates to `docker-compose.yml` to mount the initialization script and
  build the bot image locally.
- Updates to `.env.example` to include the new database environment
  variables.
- Restoration of the data dictionary to `db_tasks.md`.
2025-12-18 19:36:40 +00:00

33 lines
1.3 KiB
Python

from sqlalchemy import create_engine, Column, Integer, String, Date, Time, BigInteger, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
Base = declarative_base()
class AsistenciaRegistros(Base):
__tablename__ = 'asistencia_registros'
__table_args__ = {'schema': 'vanity_attendance'}
id_asistencia = Column(Integer, primary_key=True, autoincrement=True)
numero_empleado = Column(String(15), ForeignKey('vanity_hr.data_empleadas.numero_empleado'))
fecha = Column(Date)
hora_entrada_real = Column(Time)
hora_salida_real = Column(Time)
minutos_retraso = Column(Integer)
minutos_extra = Column(Integer)
sucursal_registro = Column(String(50))
telegram_id_usado = Column(BigInteger)
empleada = relationship("DataEmpleadas", backref="asistencia_registros")
class HorarioEmpleadas(Base):
__tablename__ = 'horario_empleadas'
__table_args__ = {'schema': 'vanity_attendance'}
id_horario = Column(Integer, primary_key=True, autoincrement=True)
numero_empleado = Column(String(15), ForeignKey('vanity_hr.data_empleadas.numero_empleado'))
telegram_id = Column(BigInteger)
dia_semana = Column(String(20))
hora_entrada_teorica = Column(Time)
hora_salida_teorica = Column(Time)
empleada = relationship("DataEmpleadas", backref="horario_empleadas")