mirror of
https://github.com/koloideal/DutyLog.git
synced 2026-06-10 10:25:29 +03:00
25 lines
1022 B
Python
25 lines
1022 B
Python
from datetime import datetime, timezone, timedelta
|
|
from enum import Enum
|
|
|
|
from sqlalchemy import BigInteger, Integer, String, DateTime, ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from dutylog.infrastructure.database.models.base import Base
|
|
from dutylog.infrastructure.utils.datetime import msk_now
|
|
|
|
|
|
class TransactionType(str, Enum):
|
|
INCREASE = "increase"
|
|
DECREASE = "decrease"
|
|
|
|
|
|
class HoursTransaction(Base):
|
|
__tablename__ = "hours_transactions"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
|
transaction_type: Mapped[str] = mapped_column(String(50), nullable=False)
|
|
amount: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
admin_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("users.id", ondelete="SET NULL"), nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=msk_now)
|