from pydantic import BaseModel, EmailStr
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime
from typing import Generator

Base = declarative_base()
class UserBase(BaseModel):
    email: EmailStr
    name: str | None = None
    
    

class UserCreate(UserBase):
    # For creating a new user in your DB if needed
    pass

class UserInDB(UserBase):
    id: int 
    hashed_password: str | None = None
    # ... other fields
    class Config:
        from_attributes = True

class Token(BaseModel):
    access_token: str
    token_type: str


class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    email = Column(String(255), unique=True, index=True, nullable=False)
    name = Column(String(255), nullable=True)
    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)


