38 lines
1011 B
Python
38 lines
1011 B
Python
"""baseline existing business tables for fresh PostgreSQL databases
|
||
|
||
Revision ID: 208b0c5d302a
|
||
Revises: 20260814_01
|
||
Create Date: 2026-08-14 18:14:07.548098
|
||
"""
|
||
from typing import Sequence, Union
|
||
|
||
from alembic import op
|
||
|
||
from app.db import Base
|
||
from app import models # noqa: F401
|
||
|
||
|
||
revision: str = '208b0c5d302a'
|
||
down_revision: Union[str, Sequence[str], None] = '20260814_01'
|
||
branch_labels: Union[str, Sequence[str], None] = None
|
||
depends_on: Union[str, Sequence[str], None] = None
|
||
|
||
|
||
def upgrade() -> None:
|
||
bind = op.get_bind()
|
||
# 线上库在引入 Alembic 前已有这些表,checkfirst 保证迁移无损;空库则完整创建。
|
||
for table_name in (
|
||
"candles",
|
||
"backtest_runs",
|
||
"stock_basic",
|
||
"market_daily",
|
||
"daily_snapshot",
|
||
"trade_calendar",
|
||
):
|
||
Base.metadata.tables[table_name].create(bind=bind, checkfirst=True)
|
||
|
||
|
||
def downgrade() -> None:
|
||
# 这些表可能包含迁移接管前的数据,禁止自动降级删除。
|
||
pass
|