from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, JSON
from sqlalchemy.orm import relationship
from models._system import Base
from models.option_opti import OptionOpti


class BaseBase(Base):
    __tablename__ = 'base_base'

    id_base = Column(
        Integer,
        primary_key=True,
        autoincrement=True
    )
    provider_base = Column(
        String(255),
        nullable=False
    )
    providercode_base = Column(
        String(255)
    )
    name_base = Column(
        String(255),
        nullable=False
    )
    alias_base = Column(
        String(255)
    )
    flyerurl_base = Column(
        String(255)
    )
    piburl_base = Column(
        String(255)
    )
    details_base = Column(
        JSON
    )
    created_base = Column(
        DateTime,
        nullable=False
    )
    updated_base = Column(
        DateTime,
        nullable=False
    )

    deals = relationship(
        "DealDeal",
        back_populates="base"
    )
    options = relationship(
        "OptionOpti",
        back_populates="base"
    )
