56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
import datetime
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import (
|
|
BigInteger,
|
|
Boolean,
|
|
DateTime,
|
|
Float,
|
|
Integer,
|
|
String,
|
|
)
|
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
class UserModel(Base):
|
|
__tablename__ = "users"
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
tg_id: Mapped[int] = mapped_column(BigInteger, unique=True)
|
|
username: Mapped[Optional[str]] = mapped_column(String(32))
|
|
date_joined: Mapped[datetime.datetime] = mapped_column(
|
|
DateTime, default=datetime.datetime.utcnow
|
|
)
|
|
balance: Mapped[int] = mapped_column(Integer, default=0)
|
|
purchased: Mapped[int] = mapped_column(Integer, default=0)
|
|
is_admin: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
|
|
|
|
class Account(Base):
|
|
__tablename__ = "accounts"
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
|
|
login: Mapped[str] = mapped_column(String)
|
|
password: Mapped[str] = mapped_column(String)
|
|
|
|
agent_count: Mapped[int] = mapped_column(Integer)
|
|
inventory_value: Mapped[int] = mapped_column(Integer)
|
|
knife_count: Mapped[int] = mapped_column(Integer)
|
|
last_rank: Mapped[str] = mapped_column(String(32))
|
|
level: Mapped[int] = mapped_column(Integer)
|
|
current_rank: Mapped[str] = mapped_column(String(32))
|
|
region: Mapped[str] = mapped_column(String(6))
|
|
skin_count: Mapped[int] = mapped_column(Integer)
|
|
price: Mapped[float] = mapped_column(Float)
|
|
|
|
valorant_points: Mapped[str] = mapped_column(Integer)
|
|
|
|
is_sold: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
buyer: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
date_purchase: Mapped[Optional[datetime.datetime]] = mapped_column(
|
|
DateTime, nullable=True
|
|
)
|