31 lines
701 B
Python
31 lines
701 B
Python
from __future__ import annotations
|
|
|
|
from enum import StrEnum
|
|
|
|
from sqlalchemy.dialects.postgresql import ENUM as PGEnum
|
|
|
|
AUTH_SCHEMA = "auth"
|
|
CONTENT_SCHEMA = "content"
|
|
COMMERCE_SCHEMA = "commerce"
|
|
PLATFORM_SCHEMA = "platform"
|
|
|
|
|
|
def pg_enum(
|
|
enum_cls: type[StrEnum],
|
|
name: str,
|
|
schema: str,
|
|
) -> PGEnum:
|
|
"""Reference a PostgreSQL enum owned by an explicit bounded context.
|
|
|
|
Enum DDL is owned by schema.sql/Alembic; ORM metadata must never create or
|
|
silently relocate PostgreSQL enum types.
|
|
"""
|
|
|
|
return PGEnum(
|
|
enum_cls,
|
|
name=name,
|
|
schema=schema,
|
|
create_type=False,
|
|
values_callable=lambda cls: [item.value for item in cls],
|
|
)
|