fix(trade-dashboard): fix import errors and alembic migration

- database.py: remove dead pre-definition of DATABASE_URL with
  undefined db_user/db_pass variables
- models.py: add missing Table import from sqlalchemy
- alembic/env.py: replace deprecated run_async() with asyncio.run()
  (removed in SQLAlchemy 2.0)
- alembic 001_initial: use raw SQL for CREATE TYPE instead of
  op.create_enum() which requires alembic_postgresql_enum

Migration 001_initial successfully applied to trading_data DB.
This commit is contained in:
sirius0xdev 2026-05-02 22:44:38 +00:00
commit 23c7c707d8
4 changed files with 8 additions and 16 deletions

View file

@ -54,8 +54,9 @@ async def run_migrations_online() -> None:
await connectable.dispose()
import asyncio
if context.is_offline_mode():
run_migrations_offline()
else:
from sqlalchemy.ext.asyncio import run_async # noqa: E402
run_async(run_migrations_online())
asyncio.run(run_migrations_online())

View file

@ -15,7 +15,7 @@ depends_on = None
def upgrade() -> None:
op.create_enum("position_direction", "long", "short", schema="public", create_type=True)
op.execute('CREATE TYPE position_direction AS ENUM (\'long\', \'short\')')
op.create_table(
"positions",