提交
This commit is contained in:
36
backend/alembic/versions/20260909_01_holding_items.py
Normal file
36
backend/alembic/versions/20260909_01_holding_items.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""holding_items:持仓股(手动标记进「持仓」分类)
|
||||
|
||||
Revision ID: 20260909_01
|
||||
Revises: 20260907_02
|
||||
Create Date: 2026-09-09
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20260909_01"
|
||||
down_revision: Union[str, Sequence[str], None] = "20260907_02"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"holding_items",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
||||
sa.Column("user_id", sa.BigInteger(), nullable=False),
|
||||
sa.Column("ts_code", sa.String(length=12), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
sa.UniqueConstraint("user_id", "ts_code", name="uq_holding_user_code"),
|
||||
)
|
||||
op.create_index("ix_holding_items_user_id", "holding_items", ["user_id"])
|
||||
op.create_index("ix_holding_items_ts_code", "holding_items", ["ts_code"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_holding_items_ts_code", table_name="holding_items")
|
||||
op.drop_index("ix_holding_items_user_id", table_name="holding_items")
|
||||
op.drop_table("holding_items")
|
||||
Reference in New Issue
Block a user