cmvr-visual/backend/alembic/env.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

45 lines
1.2 KiB
Python

import asyncio
from alembic import context
from sqlalchemy.ext.asyncio import create_async_engine
from app.models import Base
from app.core.config import Settings
config = context.config
target_metadata = Base.metadata
def include_object(obj, name, type_, reflected, compare_to):
return name.startswith("visual_") if type_ == "table" else True
def run(connection):
context.configure(
connection=connection,
target_metadata=target_metadata,
include_object=include_object,
compare_type=True,
)
with context.begin_transaction():
context.run_migrations()
async def online():
url = config.attributes.get("url") or Settings.from_env().sqlalchemy_url
engine = create_async_engine(url)
async with engine.connect() as connection:
await connection.run_sync(run)
await engine.dispose()
if context.is_offline_mode():
context.configure(
url=config.get_main_option("sqlalchemy.url"),
target_metadata=target_metadata,
literal_binds=True,
include_object=include_object,
)
with context.begin_transaction():
context.run_migrations()
else:
asyncio.run(online())