from typing import TYPE_CHECKING

from sqlalchemy import Column, ForeignKey, Integer, String, Enum, DateTime, Text
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.db.base_class import Base


if TYPE_CHECKING:
  from .user import User  # noqa: F401
  from .enum import Progress

class YTViews(Base):
  id = Column(Integer, primary_key=True, index=True)
  email = Column(String(50), index=True, nullable=False)
  name = Column(String(30), index=True)
  phone = Column(String(15), index=True)
  company = Column(String(20))
  url = Column(String(100), index=True, nullable=False)
  area = Column(String(20))
  language = Column(String(20))
  ages = Column(String(30))
  target = Column(String(50))
  theme = Column(String(20))
  taxID = Column(String(20))
  item = Column(String(20), nullable=False)
  amount = Column(Integer, nullable=False)
  created_datetime = Column(DateTime(timezone=True), default=func.now())
  payment_state = Column(String(10), default='waiting', nullable=False)
  epayment = Column(String(10), 
                    ForeignKey("epayment.name", ondelete="RESTRICT", onupdate="CASCADE"),
                    default="ecpay")
  remark = Column(Text)
  