Feat: Implement token tracking, soft delete, and Admin UI improvements

This commit is contained in:
2026-02-10 01:00:26 +08:00
parent 6924e86b8d
commit 968eb173dd
14 changed files with 1763 additions and 180 deletions

30
update_schema.py Normal file
View File

@@ -0,0 +1,30 @@
from sqlalchemy import create_engine, text
from app.core.config import settings
def update_schema():
engine = create_engine(settings.DATABASE_URL)
with engine.connect() as conn:
print("Adding token tracking columns to modules table...")
try:
conn.execute(text("ALTER TABLE modules ADD COLUMN ingress_tokens INTEGER DEFAULT 0"))
print("Added ingress_tokens column.")
except Exception as e:
print(f"ingress_tokens column might already exist: {e}")
try:
conn.execute(text("ALTER TABLE modules ADD COLUMN egress_tokens INTEGER DEFAULT 0"))
print("Added egress_tokens column.")
except Exception as e:
print(f"egress_tokens column might already exist: {e}")
try:
conn.execute(text("ALTER TABLE modules ADD COLUMN total_tokens INTEGER DEFAULT 0"))
print("Added total_tokens column.")
except Exception as e:
print(f"total_tokens column might already exist: {e}")
conn.commit()
print("Schema update complete.")
if __name__ == "__main__":
update_schema()