Files
stock/backend/alembic/versions/20260906_01_stock_company.py
2026-09-07 18:07:31 +08:00

49 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""stock_company上市公司基本信息tushare 按需懒加载 + 30 天新鲜度 + 墓碑负缓存)
Revision ID: 20260906_01
Revises: 20260905_01
Create Date: 2026-09-06
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "20260906_01"
down_revision: Union[str, Sequence[str], None] = "20260905_01"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"stock_company",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("ts_code", sa.String(length=12), nullable=False),
sa.Column("com_name", sa.String(length=255), nullable=True),
sa.Column("com_id", sa.String(length=32), nullable=True),
sa.Column("chairman", sa.String(length=128), nullable=True),
sa.Column("manager", sa.String(length=128), nullable=True),
sa.Column("secretary", sa.String(length=128), nullable=True),
sa.Column("reg_capital", sa.Float(), nullable=True),
sa.Column("setup_date", sa.String(length=8), nullable=True),
sa.Column("province", sa.String(length=32), nullable=True),
sa.Column("city", sa.String(length=32), nullable=True),
sa.Column("introduction", sa.Text(), nullable=True),
sa.Column("website", sa.String(length=255), nullable=True),
sa.Column("email", sa.String(length=255), nullable=True),
sa.Column("office", sa.String(length=255), nullable=True),
sa.Column("employees", sa.Integer(), nullable=True),
sa.Column("main_business", sa.Text(), nullable=True),
sa.Column("business_scope", sa.Text(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("ts_code", name="uq_stock_company_ts_code"),
)
op.create_index("ix_stock_company_ts_code", "stock_company", ["ts_code"])
def downgrade() -> None:
op.drop_index("ix_stock_company_ts_code", table_name="stock_company")
op.drop_table("stock_company")