rebuild(stage-7): deliver ladder and sector rotation
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
|
||||
from backend.database.migrations.runner import Migration
|
||||
|
||||
|
||||
def upgrade(connection: sqlite3.Connection) -> None:
|
||||
connection.execute(
|
||||
"""
|
||||
CREATE TABLE sector_member_snapshots (
|
||||
trade_date TEXT NOT NULL,
|
||||
sector_name TEXT NOT NULL,
|
||||
sector_code TEXT NOT NULL,
|
||||
observed_at TEXT NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
coverage REAL NOT NULL CHECK (coverage >= 0 AND coverage <= 1),
|
||||
payload_json TEXT NOT NULL,
|
||||
PRIMARY KEY (trade_date, sector_name)
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade(connection: sqlite3.Connection) -> None:
|
||||
connection.execute("DROP TABLE sector_member_snapshots")
|
||||
|
||||
|
||||
MIGRATION = Migration(
|
||||
version=4,
|
||||
name="create_sector_member_snapshots",
|
||||
signature="market:v2:dated-shenwan-sector-members",
|
||||
upgrade=upgrade,
|
||||
downgrade=downgrade,
|
||||
)
|
||||
@@ -1,6 +1,7 @@
|
||||
from backend.database.migrations.m0001_accounts import MIGRATION as ACCOUNTS
|
||||
from backend.database.migrations.m0002_model_pool import MIGRATION as MODEL_POOL
|
||||
from backend.database.migrations.m0003_market_foundation import MIGRATION as MARKET_FOUNDATION
|
||||
from backend.database.migrations.m0004_sector_members import MIGRATION as SECTOR_MEMBERS
|
||||
from backend.database.migrations.runner import Migration
|
||||
|
||||
MIGRATIONS: tuple[Migration, ...] = (ACCOUNTS, MODEL_POOL, MARKET_FOUNDATION)
|
||||
MIGRATIONS: tuple[Migration, ...] = (ACCOUNTS, MODEL_POOL, MARKET_FOUNDATION, SECTOR_MEMBERS)
|
||||
|
||||
Reference in New Issue
Block a user