| | from sqlalchemy import create_engine, Column, Integer, String, DateTime, Text, Boolean, ForeignKey, JSON |
| | from sqlalchemy.ext.declarative import declarative_base |
| | from sqlalchemy.orm import sessionmaker, relationship |
| | from datetime import datetime |
| | import uuid |
| |
|
| | Base = declarative_base() |
| |
|
| | class User(Base): |
| | __tablename__ = "users" |
| | |
| | id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) |
| | email = Column(String, unique=True, nullable=False, index=True) |
| | username = Column(String, unique=True, nullable=False, index=True) |
| | hashed_password = Column(String, nullable=False) |
| | is_active = Column(Boolean, default=True) |
| | is_verified = Column(Boolean, default=False) |
| | created_at = Column(DateTime, default=datetime.utcnow) |
| | updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) |
| | |
| | |
| | content_items = relationship("ContentItem", back_populates="owner") |
| | scheduled_posts = relationship("ScheduledPost", back_populates="owner") |
| |
|
| | class ContentItem(Base): |
| | __tablename__ = "content_items" |
| | |
| | id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) |
| | owner_id = Column(String, ForeignKey("users.id"), nullable=False) |
| | title = Column(String, nullable=False) |
| | content_type = Column(String, nullable=False) |
| | original_prompt = Column(Text) |
| | generated_content = Column(Text) |
| | platform_specific_variants = Column(JSON) |
| | tags = Column(JSON) |
| | status = Column(String, default="draft") |
| | created_at = Column(DateTime, default=datetime.utcnow) |
| | updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) |
| | |
| | |
| | owner = relationship("User", back_populates="content_items") |
| | scheduled_posts = relationship("ScheduledPost", back_populates="content_item") |
| |
|
| | class ScheduledPost(Base): |
| | __tablename__ = "scheduled_posts" |
| | |
| | id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) |
| | owner_id = Column(String, ForeignKey("users.id"), nullable=False) |
| | content_item_id = Column(String, ForeignKey("content_items.id"), nullable=False) |
| | platform = Column(String, nullable=False) |
| | scheduled_time = Column(DateTime, nullable=False) |
| | status = Column(String, default="scheduled") |
| | platform_metadata = Column(JSON) |
| | published_at = Column(DateTime) |
| | created_at = Column(DateTime, default=datetime.utcnow) |
| | |
| | |
| | owner = relationship("User", back_populates="scheduled_posts") |
| | content_item = relationship("ContentItem", back_populates="scheduled_posts") |
| |
|
| | class AIModelConfig(Base): |
| | __tablename__ = "ai_model_configs" |
| | |
| | id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) |
| | model_name = Column(String, nullable=False) |
| | model_type = Column(String, nullable=False) |
| | provider = Column(String, nullable=False) |
| | model_path = Column(String) |
| | api_endpoint = Column(String) |
| | is_active = Column(Boolean, default=True) |
| | config_params = Column(JSON) |
| | created_at = Column(DateTime, default=datetime.utcnow) |
| | updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) |
| |
|
| | class PlatformCredential(Base): |
| | __tablename__ = "platform_credentials" |
| | |
| | id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) |
| | user_id = Column(String, ForeignKey("users.id"), nullable=False) |
| | platform = Column(String, nullable=False) |
| | encrypted_credential = Column(String, nullable=False) |
| | scopes = Column(JSON) |
| | expires_at = Column(DateTime) |
| | is_active = Column(Boolean, default=True) |
| | created_at = Column(DateTime, default=datetime.utcnow) |
| | updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) |
| | |
| | user = relationship("User") |
| |
|
| | |
| | DATABASE_URL = "sqlite:///./auranexus.db" |
| | engine = create_engine(DATABASE_URL) |
| | SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) |
| |
|
| | def create_tables(): |
| | Base.metadata.create_all(bind=engine) |