48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
from sqlalchemy import Column, Integer, String, DateTime, Float, Text, Index
|
|
from app.models.base import BaseModel
|
|
|
|
|
|
class BillingBatch(BaseModel):
|
|
__tablename__ = "billing_batches"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
batch_id = Column(String(100), unique=True, nullable=False, index=True)
|
|
status = Column(String(32), nullable=False)
|
|
total_files = Column(Integer, nullable=False, default=0)
|
|
successful_files = Column(Integer, nullable=False, default=0)
|
|
failed_files = Column(Integer, nullable=False, default=0)
|
|
started_at = Column(DateTime(timezone=True), nullable=False)
|
|
updated_at = Column(DateTime(timezone=True))
|
|
completed_at = Column(DateTime(timezone=True))
|
|
processing_time_seconds = Column(Float)
|
|
success_rate = Column(Float)
|
|
error_message = Column(Text)
|
|
|
|
__table_args__ = (
|
|
Index("ix_billing_batches_started_at", "started_at"),
|
|
Index("ix_billing_batches_updated_at", "updated_at"),
|
|
Index("ix_billing_batches_completed_at", "completed_at"),
|
|
{},
|
|
)
|
|
|
|
|
|
class BillingBatchFile(BaseModel):
|
|
__tablename__ = "billing_batch_files"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
batch_id = Column(String(100), nullable=False, index=True)
|
|
file_no = Column(String(50), nullable=False, index=True)
|
|
status = Column(String(32), nullable=False)
|
|
error_message = Column(Text)
|
|
filename = Column(String(255))
|
|
size = Column(Integer)
|
|
started_at = Column(DateTime(timezone=True))
|
|
completed_at = Column(DateTime(timezone=True))
|
|
|
|
__table_args__ = (
|
|
Index("ix_billing_batch_files_batch_file", "batch_id", "file_no"),
|
|
{},
|
|
)
|
|
|
|
|