Files
richardtekula f78c2199e1 Fix: Rename directory to remove & character causing shell issues
Renamed ebook_backend&admin_panel to ebook_backend_admin_panel
  The & character was being interpreted by shell as background
  process operator, causing 'Dockerfile not found' errors in Coolify.
2025-11-11 17:06:39 +01:00

23 lines
892 B
Python

from sqlalchemy import Column, Integer, String, DateTime
from datetime import datetime
import pytz
from utils.auth import Base
class Coupon(Base):
"""
SQLAlchemy model representing a coupon code entry in the database.
Attributes:
id (int): Primary key identifier.
code (str): Unique coupon code string.
usage_count (int): Number of times the coupon has been used.
created_at (datetime): Timestamp of coupon creation (stored in Europe/Bratislava timezone).
used_at (datetime | None): Timestamp of the last usage, nullable.
"""
__tablename__ = "coupon_codes"
id = Column(Integer, primary_key=True)
code = Column(String, unique=True)
usage_count = Column(Integer, default=0)
created_at = Column(DateTime, default=lambda: datetime.now(pytz.timezone('Europe/Bratislava')))
used_at = Column(DateTime, nullable=True)