62 lines
2 KiB
Python
62 lines
2 KiB
Python
# packages/v1/administrativo/models/ato_documento_model.py
|
|
# Gerado a partir da DDL da tabela 'ato_documento'
|
|
|
|
from sqlalchemy import (
|
|
Column,
|
|
BigInteger,
|
|
String,
|
|
DateTime,
|
|
Text, # Necessário para o campo 'url'
|
|
ForeignKey, # Necessário para a chave estrangeira
|
|
)
|
|
|
|
from sqlalchemy.sql import func
|
|
|
|
# Importa Base do MySQL (assumindo que o caminho 'database.mysql' é o correto)
|
|
from database.mysql import Base
|
|
|
|
|
|
class AtoDocumento(Base):
|
|
"""
|
|
Representa o modelo da tabela 'ato_documento' no banco de dados MySQL.
|
|
Mapeia a DDL fornecida.
|
|
"""
|
|
|
|
__tablename__ = "ato_documento"
|
|
|
|
# ato_documento_id bigint unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY
|
|
ato_documento_id = Column(BigInteger, primary_key=True, autoincrement=True)
|
|
|
|
# ato_principal_id bigint NOT NULL, FOREIGN KEY
|
|
# Mapeamento da chave estrangeira
|
|
ato_principal_id = Column(
|
|
BigInteger, ForeignKey("ato_principal.ato_principal_id"), nullable=False
|
|
)
|
|
|
|
# url text NOT NULL (URL pública HTTPS do documento)
|
|
url = Column(Text, nullable=False)
|
|
|
|
# nome_documento varchar(255) NOT NULL (Nome do arquivo PDF)
|
|
nome_documento = Column(String(255), nullable=False)
|
|
|
|
# tipo_documento varchar(50) NOT NULL (Tipo textual do documento)
|
|
tipo_documento = Column(String(50), nullable=False)
|
|
|
|
# created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
|
|
|
# updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
updated_at = Column(
|
|
DateTime,
|
|
server_default=func.now(), # Default CURRENT_TIMESTAMP
|
|
onupdate=func.now(), # ON UPDATE CURRENT_TIMESTAMP
|
|
nullable=False,
|
|
)
|
|
|
|
def __repr__(self):
|
|
"""Representação legível do objeto."""
|
|
return (
|
|
f"<AtoDocumento(ato_documento_id={self.ato_documento_id}, "
|
|
f"ato_principal_id={self.ato_principal_id}, "
|
|
f"tipo_documento='{self.tipo_documento}')>"
|
|
)
|