From ebea86236003b4b961b9eaf646a4518be7651570 Mon Sep 17 00:00:00 2001 From: CosLynx AI Date: Fri, 18 Oct 2024 08:00:10 +0530 Subject: [PATCH] generated file: `migrations/env.py` --- migrations/env.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 migrations/env.py diff --git a/migrations/env.py b/migrations/env.py new file mode 100644 index 0000000..30ecd42 --- /dev/null +++ b/migrations/env.py @@ -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() \ No newline at end of file