Moved models to shared base

This commit is contained in:
2025-09-23 19:27:08 +01:00
parent 7d811fede0
commit 3eaed88074
5 changed files with 26 additions and 16 deletions

View File

@@ -1,9 +1,8 @@
from sqlalchemy.orm import declarative_base
from app.db.base_class import Base # noqa: F401
# Import all models so their tables are registered on Base.metadata
from app.models.user import User # noqa: F401
from app.models.server import Server # noqa: F401
from app.models.sshkey import SSHKey # noqa: F401
from app.models.access_request import AccessRequest # noqa: F401
from app.models.audit import AuditEvent # noqa: F401
from app.models.server import Server # noqa: F401
from app.models.sshkey import SSHKey # noqa: F401
from app.models.user import User # noqa: F401
Base = declarative_base()
from app.models.audit import AuditEvent # noqa: F401

13
app/db/base_class.py Normal file
View File

@@ -0,0 +1,13 @@
from sqlalchemy import MetaData
from sqlalchemy.orm import declarative_base
# Optional: naming convention keeps Alembic diffs stable
convention = {
"ix": "ix_%(column_0_label)s",
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s",
}
metadata = MetaData(naming_convention=convention)
Base = declarative_base(metadata=metadata)