"""SQLAlchemy 2.0 Declarative Base。 所有 ORM model 继承 `Base`。Alembic 通过 `Base.metadata` 拿到完整表结构生成 migration。 """ from __future__ import annotations from sqlalchemy.orm import DeclarativeBase, MappedAsDataclass class Base(DeclarativeBase): """所有 model 的公共基类。""" # 在 Alembic env.py 里 import Base 才能扫描到所有 model, # 这里也 import 一次确保 metadata 包含全部表。 # (新增 model 时记得加到 app.models.__init__ 里) from app import models # noqa: E402,F401