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,
|
||||
)
|
||||
Reference in New Issue
Block a user