import pytz
import datetime
from sqlalchemy import (
    Column,
    BigInteger,
    Text,
    DateTime,
)
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class PostcodeSearchModel(Base):
    __tablename__ = "postcode_search"

    id = Column(BigInteger, primary_key=True, autoincrement=True)
    postcode = Column(Text, nullable=False)
    result_data = Column(JSONB, nullable=True)

    created_at = Column(
        DateTime(timezone=True), nullable=False, default=datetime.datetime.now(pytz.utc)
    )
