37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""add adj_factor table (复权因子底座)
|
|
|
|
Revision ID: 20260815_01
|
|
Revises: 208b0c5d302a
|
|
Create Date: 2026-08-15
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = "20260815_01"
|
|
down_revision: Union[str, Sequence[str], None] = "208b0c5d302a"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"adj_factor",
|
|
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column("trade_date", sa.DateTime(), nullable=False),
|
|
sa.Column("ts_code", sa.String(length=12), nullable=False),
|
|
sa.Column("adj_factor", sa.Float(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("ts_code", "trade_date", name="uq_adj_code_date"),
|
|
)
|
|
op.create_index("ix_adj_factor_trade_date", "adj_factor", ["trade_date"])
|
|
op.create_index("ix_adj_factor_ts_code", "adj_factor", ["ts_code"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_adj_factor_ts_code", table_name="adj_factor")
|
|
op.drop_index("ix_adj_factor_trade_date", table_name="adj_factor")
|
|
op.drop_table("adj_factor")
|