e4e2595e70
- adapters: SQLAlchemy implementations for all 4 repositories (Project, AssetLibrary, Asset, IngestJob) - models: SQLAlchemy ORM models with proper schema - database: connection config and session management - tests: SQLAlchemy repository integration test (in-memory SQLite) - all 7 integration tests passing
56 lines
2.3 KiB
Python
56 lines
2.3 KiB
Python
from sqlalchemy import Column, DateTime, String, Text, create_engine
|
|
from sqlalchemy.orm import declarative_base
|
|
from datetime import datetime, timezone
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
class ProjectModel(Base):
|
|
__tablename__ = "projects"
|
|
|
|
id = Column(String(32), primary_key=True)
|
|
workspace_id = Column(String(32), nullable=False, index=True)
|
|
name = Column(String(100), nullable=False)
|
|
description = Column(Text, nullable=False, default="")
|
|
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
|
|
|
|
|
class AssetLibraryModel(Base):
|
|
__tablename__ = "asset_libraries"
|
|
|
|
id = Column(String(32), primary_key=True)
|
|
workspace_id = Column(String(32), nullable=False, index=True)
|
|
project_id = Column(String(32), nullable=False, index=True)
|
|
name = Column(String(100), nullable=False)
|
|
kind = Column(String(20), nullable=False)
|
|
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
|
|
|
|
|
class AssetModel(Base):
|
|
__tablename__ = "assets"
|
|
|
|
id = Column(String(32), primary_key=True)
|
|
workspace_id = Column(String(32), nullable=False, index=True)
|
|
project_id = Column(String(32), nullable=False, index=True)
|
|
library_id = Column(String(32), nullable=False, index=True)
|
|
name = Column(String(100), nullable=False)
|
|
storage_key = Column(String(255), nullable=False)
|
|
mime_type = Column(String(100), nullable=False)
|
|
metadata_json = Column(Text, nullable=False, default="{}")
|
|
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
|
|
|
|
|
class IngestJobModel(Base):
|
|
__tablename__ = "ingest_jobs"
|
|
|
|
id = Column(String(32), primary_key=True)
|
|
workspace_id = Column(String(32), nullable=False, index=True)
|
|
project_id = Column(String(32), nullable=False, index=True)
|
|
library_id = Column(String(32), nullable=False, index=True)
|
|
storage_key = Column(String(255), nullable=False)
|
|
status = Column(String(20), nullable=False, default="pending")
|
|
error_message = Column(Text, nullable=False, default="")
|
|
result_asset_id = Column(String(32), nullable=False, default="")
|
|
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
|
updated_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|