chore: initialize project repository
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from logging.config import fileConfig
|
||||
|
||||
from alembic import context
|
||||
from app.core.config import get_settings
|
||||
|
||||
if context.config.config_file_name is not None:
|
||||
fileConfig(context.config.config_file_name)
|
||||
|
||||
config = context.config
|
||||
sync_url = get_settings().mysql_dsn.replace("mysql+asyncmy://", "mysql+pymysql://")
|
||||
config.set_main_option("sqlalchemy.url", sync_url.replace("%", "%%"))
|
||||
target_metadata = None
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
context.configure(url=config.get_main_option("sqlalchemy.url"), literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"})
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
connectable = engine_from_config(config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.", poolclass=pool.NullPool)
|
||||
with connectable.connect() as connection:
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
Reference in New Issue
Block a user