lablup / lablup/backend.ai

Add explicit model imports to Alembic env.py

Open
#7,675 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Overview

Update `alembic/env.py` to explicitly import all model modules. This is a prerequisite for the models package restructuring.

## Background

Currently, `env.py` only imports a subset of models:

```python
import ai.backend.manager.models.agent # noqa
import ai.backend.manager.models.kernel # noqa
import ai.backend.manager.models.keypair # noqa
import ai.backend.manager.models.vfolder # noqa
import ai.backend.manager.models.event_log # noqa
import ai.backend.manager.models.rbac_models # noqa
```

When `models/__init__.py` stops eagerly importing all modules, Alembic needs explicit imports to register tables with metadata.

## Tasks

- [ ] Add explicit imports for all model modules in `alembic/env.py`
- [ ] Consider using `pkgutil.iter_modules()` for automatic discovery

## Acceptance Criteria

- [ ] `alembic upgrade head` works correctly
- [ ] `alembic revision --autogenerate` detects all tables
- [ ] No regression in existing migrations

JIRA Issue: BA-3618

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.