23 lines
923 B
Python
23 lines
923 B
Python
from sqlalchemy import Column, Integer, String, Text, ForeignKey, DateTime
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class AuditLog(Base):
|
|
__tablename__ = "audit_logs"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
medicine_id = Column(Integer, ForeignKey("medicines.id"), nullable=False, index=True)
|
|
batch_id = Column(Integer, ForeignKey("batches.id"))
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
action = Column(String(50), nullable=False)
|
|
quantity_change = Column(Integer, nullable=False)
|
|
quantity_after = Column(Integer, nullable=False)
|
|
remark = Column(Text)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
|
|
medicine = relationship("Medicine", back_populates="audit_logs")
|
|
batch = relationship("Batch", back_populates="audit_logs")
|
|
user = relationship("User", back_populates="audit_logs") |