Files
Document_Translator/fix_table_simple.py
2025-09-04 09:44:13 +08:00

42 lines
1.2 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
修正通知表腳本
"""
from app import create_app, db
from sqlalchemy import text
def fix_notification_table():
"""修正通知表"""
try:
app = create_app()
with app.app_context():
print("Fixing notification table...")
# 刪除通知表(如果存在)
try:
db.session.execute(text('DROP TABLE IF EXISTS dt_notifications'))
db.session.commit()
print("Old notification table dropped")
except Exception as e:
print(f"Info: {e}")
# 重新創建通知表
db.create_all()
print("New notification table created with correct structure")
# 檢查表結構
result = db.session.execute(text('DESCRIBE dt_notifications'))
columns = result.fetchall()
print("New table structure:")
for col in columns:
print(f" {col[0]} {col[1]}")
except Exception as e:
print(f"Error fixing notification table: {e}")
import traceback
traceback.print_exc()
if __name__ == '__main__':
fix_notification_table()