repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import os |
| #2 | import sys |
| #3 | from logging.config import fileConfig |
| #4 | |
| #5 | from alembic import context |
| #6 | from dotenv import load_dotenv |
| #7 | from sqlalchemy import engine_from_config, pool |
| #8 | |
| #9 | # Add the parent directory to the Python path |
| #10 | sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| #11 | |
| #12 | # Load environment variables |
| #13 | load_dotenv() |
| #14 | |
| #15 | # Import your models here - moved after path setup |
| #16 | from app.database import Base # noqa: E402 |
| #17 | |
| #18 | # this is the Alembic Config object, which provides |
| #19 | # access to the values within the .ini file in use. |
| #20 | config = context.config |
| #21 | |
| #22 | # Interpret the config file for Python logging. |
| #23 | # This line sets up loggers basically. |
| #24 | if config.config_file_name is not None: |
| #25 | fileConfig(config.config_file_name) |
| #26 | |
| #27 | # add your model's MetaData object here |
| #28 | # for 'autogenerate' support |
| #29 | target_metadata = Base.metadata |
| #30 | |
| #31 | # other values from the config, defined by the needs of env.py, |
| #32 | # can be acquired: |
| #33 | # my_important_option = config.get_main_option("my_important_option") |
| #34 | # ... etc. |
| #35 | |
| #36 | |
| #37 | def run_migrations_offline() -> None: |
| #38 | """Run migrations in 'offline' mode. |
| #39 | |
| #40 | This configures the context with just a URL |
| #41 | and not an Engine, though an Engine is acceptable |
| #42 | here as well. By skipping the Engine creation |
| #43 | we don't even need a DBAPI to be available. |
| #44 | |
| #45 | Calls to context.execute() here emit the given string to the |
| #46 | script output. |
| #47 | |
| #48 | """ |
| #49 | url = os.getenv("DATABASE_URL", "sqlite:///./openmemory.db") |
| #50 | context.configure( |
| #51 | url=url, |
| #52 | target_metadata=target_metadata, |
| #53 | literal_binds=True, |
| #54 | dialect_opts={"paramstyle": "named"}, |
| #55 | ) |
| #56 | |
| #57 | with context.begin_transaction(): |
| #58 | context.run_migrations() |
| #59 | |
| #60 | |
| #61 | def run_migrations_online() -> None: |
| #62 | """Run migrations in 'online' mode. |
| #63 | |
| #64 | In this scenario we need to create an Engine |
| #65 | and associate a connection with the context. |
| #66 | |
| #67 | """ |
| #68 | configuration = config.get_section(config.config_ini_section) |
| #69 | configuration["sqlalchemy.url"] = os.getenv("DATABASE_URL", "sqlite:///./openmemory.db") |
| #70 | connectable = engine_from_config( |
| #71 | configuration, |
| #72 | prefix="sqlalchemy.", |
| #73 | poolclass=pool.NullPool, |
| #74 | ) |
| #75 | |
| #76 | with connectable.connect() as connection: |
| #77 | context.configure( |
| #78 | connection=connection, target_metadata=target_metadata |
| #79 | ) |
| #80 | |
| #81 | with context.begin_transaction(): |
| #82 | context.run_migrations() |
| #83 | |
| #84 | |
| #85 | if context.is_offline_mode(): |
| #86 | run_migrations_offline() |
| #87 | else: |
| #88 | run_migrations_online() |
| #89 |