Skip to content

Commit

Permalink
generated file: migrations/env.py
Browse files Browse the repository at this point in the history
  • Loading branch information
coslynx committed Oct 18, 2024
1 parent 3a91d34 commit ebea862
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions migrations/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig

# this is the Alembic Config object, which provides access to the values within the .ini file
config = context.config
fileConfig(config.config_file_name)

# Interpret the config file for Python logging.
# This line sets up logging so that you can see progress as the migration proceeds.
# fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ...


def run_migrations_online():
"""Run migrations in 'online' mode."""
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, compare_type=True
)

with context.begin_transaction():
context.run_migrations()


def run_migrations_offline():
"""Run migrations in 'offline' mode."""
context.configure(url=config.get_main_option("sqlalchemy.url"))

with context.begin_transaction():
context.run_migrations()


if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

0 comments on commit ebea862

Please sign in to comment.