feat: added initial config

This commit is contained in:
2024-10-10 15:51:41 +02:00
parent 86e82a4d94
commit 5e990a615e
26 changed files with 694 additions and 4 deletions

43
alembic/env.py Normal file
View File

@@ -0,0 +1,43 @@
from logging.config import fileConfig
from dotenv import load_dotenv
from sqlalchemy import create_engine
from alembic import context
load_dotenv()
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# Our models
from app.services.db.models import Base
target_metadata = Base.metadata
def run_migrations() -> None:
from creyPY.fastapi.db.session import SQLALCHEMY_DATABASE_URL, name
with create_engine(SQLALCHEMY_DATABASE_URL + name, pool_pre_ping=True).connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
compare_type=True,
compare_server_default=True,
render_as_batch=True,
)
with context.begin_transaction():
context.run_migrations()
run_migrations()