Initial commit
Some checks failed
Run linters on applied template / Python 3.13 lint and build (push) Failing after 39s
Some checks failed
Run linters on applied template / Python 3.13 lint and build (push) Failing after 39s
This is a FastAPI backend microservice template used with `copier` utility. Features of applied template are: - Configuration file processing logic - Metrics and tracing (both optional) configuration available - Debug endpoints - Database migration commands, prepared Alembic environment - Database usage example in ping_db endpoint - gitea sanity check pipeline
This commit is contained in:
21
{{project_slug}}/db/__init__.py
Normal file
21
{{project_slug}}/db/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""SQL naming convention for Alembic is defined here."""
|
||||
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
convention = {
|
||||
"all_column_names": lambda constraint, _: "_".join([str(column.name) for column in constraint.columns.values()]),
|
||||
"ix": "ix_%(table_name)s_%(all_column_names)s",
|
||||
"uq": "%(table_name)s_%(all_column_names)s_key",
|
||||
"ck": "ck_%(table_name)s_%(column_0_name)s",
|
||||
"fk": "%(table_name)s_fk_%(all_column_names)s__%(referred_table_name)s",
|
||||
"pk": "%(table_name)s_pk",
|
||||
}
|
||||
|
||||
metadata = MetaData(naming_convention=convention)
|
||||
DeclarativeBase = declarative_base(metadata=metadata)
|
||||
|
||||
__all__ = [
|
||||
"DeclarativeBase",
|
||||
"metadata",
|
||||
]
|
||||
Reference in New Issue
Block a user