"""
SQLAlchemy models, one file per business area.

Importing any model module imports this package first, which registers every model
with Base.metadata. Relationships refer to other models by class name, so all of them
must be registered before the mappers are configured.

Table descriptions from table_catalog are attached to the metadata so Alembic
autogenerate sees the same COMMENT ON TABLE that the database has.
"""
from app.core.database import Base
from app.models.table_catalog import table_descriptions
from app.models import (  # noqa: F401
    core_models,
    access_models,
    rm_models,
    location_models,
    dealer_models,
    sales_models,
    yard_models,
    bom_models,
    procurement_models,
    vendor_portal,
    maintenance_models,
    dispatch_models,
    production_models,
    production_report_models,
    qa_models,
    master_list_models,
    station_work_models,
    notification_models,
)

for _name, _description in table_descriptions().items():
    if _name in Base.metadata.tables:
        Base.metadata.tables[_name].comment = _description
