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 | |
| #3 | from alembic import context |
| #4 | from sqlalchemy import engine_from_config, pool |
| #5 | |
| #6 | from embedchain.core.db.models import Base |
| #7 | |
| #8 | # this is the Alembic Config object, which provides |
| #9 | # access to the values within the .ini file in use. |
| #10 | config = context.config |
| #11 | |
| #12 | target_metadata = Base.metadata |
| #13 | |
| #14 | # other values from the config, defined by the needs of env.py, |
| #15 | # can be acquired: |
| #16 | # my_important_option = config.get_main_option("my_important_option") |
| #17 | # ... etc. |
| #18 | config.set_main_option("sqlalchemy.url", os.environ.get("EMBEDCHAIN_DB_URI")) |
| #19 | |
| #20 | |
| #21 | def run_migrations_offline() -> None: |
| #22 | """Run migrations in 'offline' mode. |
| #23 | |
| #24 | This configures the context with just a URL |
| #25 | and not an Engine, though an Engine is acceptable |
| #26 | here as well. By skipping the Engine creation |
| #27 | we don't even need a DBAPI to be available. |
| #28 | |
| #29 | Calls to context.execute() here emit the given string to the |
| #30 | script output. |
| #31 | |
| #32 | """ |
| #33 | url = config.get_main_option("sqlalchemy.url") |
| #34 | context.configure( |
| #35 | url=url, |
| #36 | target_metadata=target_metadata, |
| #37 | literal_binds=True, |
| #38 | dialect_opts={"paramstyle": "named"}, |
| #39 | ) |
| #40 | |
| #41 | with context.begin_transaction(): |
| #42 | context.run_migrations() |
| #43 | |
| #44 | |
| #45 | def run_migrations_online() -> None: |
| #46 | """Run migrations in 'online' mode. |
| #47 | |
| #48 | In this scenario we need to create an Engine |
| #49 | and associate a connection with the context. |
| #50 | |
| #51 | """ |
| #52 | connectable = engine_from_config( |
| #53 | config.get_section(config.config_ini_section, {}), |
| #54 | prefix="sqlalchemy.", |
| #55 | poolclass=pool.NullPool, |
| #56 | ) |
| #57 | |
| #58 | with connectable.connect() as connection: |
| #59 | context.configure(connection=connection, target_metadata=target_metadata) |
| #60 | |
| #61 | with context.begin_transaction(): |
| #62 | context.run_migrations() |
| #63 | |
| #64 | |
| #65 | if context.is_offline_mode(): |
| #66 | run_migrations_offline() |
| #67 | else: |
| #68 | run_migrations_online() |
| #69 |