Files
Atrium/backend/app/models/__init__.py
T

62 lines
2.5 KiB
Python

"""Every model must be imported here.
The migration builds tables from `Base.metadata`, so a model that is never imported silently
never gets a table — and the failure surfaces much later, as a missing relation at runtime.
The shared tables are not defined here: identity (`app_user`, `session`, `module_permission`,
`app_setting`, `audit_log`) and the org tree (`node`, `permission_grant`, `favorite`) live in
**dredd-core**, and importing `dredd_core` is what registers them on `Base.metadata`. This module
re-exports them under the names the rest of the app already uses, so every call site stays
`from ..models import AppUser, Node` regardless of where the class is declared.
Three of those — `app_user`, `session` and `module_permission`, i.e.
`dredd_core.identity.SHARED_IDENTITY_TABLES` — move OUT of this app's schema when the family runs
as one platform: revision 0004 builds them in the shared identity schema and drops the local copies.
They stay on `Base.metadata` either way, because the models are the same models and every query in
this app reaches them by `search_path` and not by schema name. What changes is only where the rows
physically live, and `assert_identity_schema` in the lifespan is what proves that is still true.
Atrium's own models live next to this file and are imported below.
"""
from dredd_core import (
AppSetting,
AppUser,
AuditLog,
Base,
Favorite,
ModulePermission,
Node,
PermissionGrant,
SafeInet,
Session,
TimestampMixin,
UUIDPkMixin,
pg_enum,
)
# Opt-in (dredd-core 0.15.0): registers `model_provider`, `model_provider_policy` and
# `model_provider_key` on the metadata. Atrium is the hub that writes them; on the platform they live
# in the identity schema (revision 0009), standalone in Atrium's own like any table.
from dredd_core.model_providers import ModelProvider, ModelProviderKey, ModelProviderPolicy
from .marketplace import AccessRequest, Module, ModuleAssignment
from .skills import (
Agent,
AgentVersion,
AgentVersionSkill,
PublishRequest,
Skill,
SkillFile,
SkillVersion,
)
__all__ = [
"Base", "TimestampMixin", "UUIDPkMixin", "SafeInet", "pg_enum",
"AppUser", "Session", "ModulePermission", "AppSetting", "AuditLog",
"Node", "PermissionGrant", "Favorite",
"Module", "ModuleAssignment", "AccessRequest",
"Skill", "SkillVersion", "SkillFile", "Agent", "AgentVersion", "AgentVersionSkill",
"PublishRequest",
"ModelProvider", "ModelProviderPolicy", "ModelProviderKey",
]