Database Module
The cellarium.cas_backend.core.db package contains the relational persistence layer for CAS Backend.
It defines SQLAlchemy models, Alembic migration configuration, and helper operations used by the app layer.
What Lives Here
models/: SQLAlchemy models for users, cell-related records, and ML management metadataops.py: shared database operationsalembic.iniandmigrations/: Alembic configuration and migration historyfield_type_decorators.py: shared SQLAlchemy field helpers
Public Entry Points
cellarium.cas_backend.core.db.modelscellarium.cas_backend.core.db.opsAlembic config at
cellarium/cas_backend/core/db/alembic.ini
Dependencies
This package is used by the admin and compute services. Runtime configuration comes from
cellarium.cas_backend.core.config.settings.
Environment and Connection
Local development reads database settings from settings/.env. The code supports:
local PostgreSQL connections via
DB_HOST,DB_PORT,DB_USER,DB_PASSWORD, andDB_NAMECloud SQL connections via
DB_INSTANCE_UNIX_SOCKETorDB_PRIVATE_IPwith the same credential variables
The SQLAlchemy URI is assembled in cellarium.cas_backend.core.config.
Database Migrations
Generate a migration:
alembic -c cellarium/cas_backend/core/db/alembic.ini revision --autogenerate -m "describe_change"
Apply migrations:
alembic -c cellarium/cas_backend/core/db/alembic.ini upgrade head