landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"""Plugin management models."""
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from sqlalchemy import String, ForeignKey, JSON, Boolean
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class PluginStatus(str, Enum):
|
||||
ACTIVE = "active"
|
||||
INACTIVE = "inactive"
|
||||
DEPRECATED = "deprecated"
|
||||
|
||||
|
||||
class Plugin(Base):
|
||||
__tablename__ = "plugins"
|
||||
|
||||
id: Mapped[UUID] = mapped_column(primary_key=True, default=uuid4)
|
||||
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
slug: Mapped[str] = mapped_column(String(100), unique=True, nullable=False)
|
||||
description: Mapped[str | None]
|
||||
version: Mapped[str] = mapped_column(String(20), nullable=False)
|
||||
author: Mapped[str | None] = mapped_column(String(100))
|
||||
config_schema: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
is_system: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
status: Mapped[PluginStatus] = mapped_column(default=PluginStatus.ACTIVE)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
tenant_installations: Mapped[list["TenantPlugin"]] = relationship(
|
||||
back_populates="plugin"
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Plugin {self.slug}@{self.version}>"
|
||||
|
||||
|
||||
class TenantPlugin(Base):
|
||||
__tablename__ = "tenant_plugins"
|
||||
|
||||
tenant_id: Mapped[UUID] = mapped_column(
|
||||
ForeignKey("tenants.id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
plugin_id: Mapped[UUID] = mapped_column(
|
||||
ForeignKey("plugins.id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
config: Mapped[dict] = mapped_column(JSON, default=dict)
|
||||
installed_by: Mapped[UUID | None] = mapped_column(ForeignKey("users.id"))
|
||||
installed_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
|
||||
status: Mapped[str] = mapped_column(default="active")
|
||||
|
||||
# Relationships
|
||||
tenant: Mapped["Tenant"] = relationship(back_populates="installed_plugins")
|
||||
plugin: Mapped["Plugin"] = relationship(back_populates="tenant_installations")
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<TenantPlugin {self.tenant_id}:{self.plugin_id}>"
|
||||
Reference in New Issue
Block a user