from datetime import datetime
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship
from sqlalchemy.sql.sqltypes import Boolean, DateTime
from database import Base
from blog.models.blog import Blog


class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True, index=True)
    user_identifier = Column(String)
    name = Column(String, nullable=False)
    email = Column(String, unique=True)
    phone_number = Column(String)
    role = Column(String)
    username = Column(String, unique=True)
    password = Column(String, nullable=False)
    is_active = Column(Boolean, default=False, nullable=False)
    is_confirmed = Column(Boolean, default=False, nullable=False)
    created_at = Column(DateTime, default=datetime.now(), nullable=True)
    blog = relationship(Blog, backref='author')
