Setup exports in the infra __init__.py

This helps avoid issues where model classes are not evaluated. If the models
are not properly imported then Sqlalchemy can explode during database initialization
since the mapped columns have not yet been registered.

Later, having the models all imported into __init__.py will help with setting
up a test db since it will ensure that the registrations for all models is happening
as the classes are evaluated during the imports in the package init file.
This commit is contained in:
Campbell Alden 2026-09-03 22:57:55 +09:00
parent f44f054f56
commit 0d270c9cfb
2 changed files with 28 additions and 2 deletions

View file

@ -0,0 +1,27 @@
from .db import Base, CRUD, CRUDRepo, UpdateMissingEntryError, get_database
from .users import UserModel, UserRepoImpl
from .publication import (
PublicationEntryModel,
PublicationSequenceModel,
PublicationOrderModel,
PublicationModel,
PublicationRepoImpl,
)
from .subscription import SubscriptionModel, SubscriptionRepoImpl
__all__ = [
'Base',
'CRUD',
'CRUDRepo',
'UpdateMissingEntryError',
'get_database',
'UserModel',
'UserRepoImpl',
'PublicationEntryModel',
'PublicationSequenceModel',
'PublicationOrderModel',
'PublicationModel',
'PublicationRepoImpl',
'SubscriptionModel',
'SubscriptionRepoImpl',
]

View file

@ -6,8 +6,7 @@ from src.services.email import EmailService, get_email_service
from src.services.auth import AuthService from src.services.auth import AuthService
from src.services.users.service import UserService from src.services.users.service import UserService
from dataclasses import dataclass from dataclasses import dataclass
from src.infra.db import get_database from src.infra import get_database, UserRepoImpl
from src.infra.users import UserRepoImpl
from waitress import serve from waitress import serve
from flask import Flask from flask import Flask
import argparse import argparse